mirror of
https://github.com/jesseduffield/lazygit.git
synced 2025-08-07 22:02:56 +03:00
Use our new hyperlink support in confirmations
This commit is contained in:
@@ -259,11 +259,7 @@ func underlineLinks(text string) string {
|
|||||||
} else {
|
} else {
|
||||||
linkEnd += linkStart
|
linkEnd += linkStart
|
||||||
}
|
}
|
||||||
underlinedLink := style.AttrUnderline.Sprint(remaining[linkStart:linkEnd])
|
underlinedLink := style.PrintSimpleHyperlink(remaining[linkStart:linkEnd])
|
||||||
if strings.HasSuffix(underlinedLink, "\x1b[0m") {
|
|
||||||
// Replace the "all styles off" code with "underline off" code
|
|
||||||
underlinedLink = underlinedLink[:len(underlinedLink)-2] + "24m"
|
|
||||||
}
|
|
||||||
result += remaining[:linkStart] + underlinedLink
|
result += remaining[:linkStart] + underlinedLink
|
||||||
remaining = remaining[linkEnd:]
|
remaining = remaining[linkEnd:]
|
||||||
}
|
}
|
||||||
|
@@ -27,27 +27,27 @@ func Test_underlineLinks(t *testing.T) {
|
|||||||
{
|
{
|
||||||
name: "entire string is a link",
|
name: "entire string is a link",
|
||||||
text: "https://example.com",
|
text: "https://example.com",
|
||||||
expectedResult: "\x1b[4mhttps://example.com\x1b[24m",
|
expectedResult: "\x1b]8;;https://example.com\x1b\\https://example.com\x1b]8;;\x1b\\",
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
name: "link preceeded and followed by text",
|
name: "link preceeded and followed by text",
|
||||||
text: "bla https://example.com xyz",
|
text: "bla https://example.com xyz",
|
||||||
expectedResult: "bla \x1b[4mhttps://example.com\x1b[24m xyz",
|
expectedResult: "bla \x1b]8;;https://example.com\x1b\\https://example.com\x1b]8;;\x1b\\ xyz",
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
name: "more than one link",
|
name: "more than one link",
|
||||||
text: "bla https://link1 blubb https://link2 xyz",
|
text: "bla https://link1 blubb https://link2 xyz",
|
||||||
expectedResult: "bla \x1b[4mhttps://link1\x1b[24m blubb \x1b[4mhttps://link2\x1b[24m xyz",
|
expectedResult: "bla \x1b]8;;https://link1\x1b\\https://link1\x1b]8;;\x1b\\ blubb \x1b]8;;https://link2\x1b\\https://link2\x1b]8;;\x1b\\ xyz",
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
name: "link in angle brackets",
|
name: "link in angle brackets",
|
||||||
text: "See <https://example.com> for details",
|
text: "See <https://example.com> for details",
|
||||||
expectedResult: "See <\x1b[4mhttps://example.com\x1b[24m> for details",
|
expectedResult: "See <\x1b]8;;https://example.com\x1b\\https://example.com\x1b]8;;\x1b\\> for details",
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
name: "link followed by newline",
|
name: "link followed by newline",
|
||||||
text: "URL: https://example.com\nNext line",
|
text: "URL: https://example.com\nNext line",
|
||||||
expectedResult: "URL: \x1b[4mhttps://example.com\x1b[24m\nNext line",
|
expectedResult: "URL: \x1b]8;;https://example.com\x1b\\https://example.com\x1b]8;;\x1b\\\nNext line",
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -109,14 +109,6 @@ func (gui *Gui) scrollDownConfirmationPanel() error {
|
|||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (gui *Gui) handleConfirmationClick() error {
|
|
||||||
if gui.Views.Confirmation.Editable {
|
|
||||||
return nil
|
|
||||||
}
|
|
||||||
|
|
||||||
return gui.handleGenericClick(gui.Views.Confirmation)
|
|
||||||
}
|
|
||||||
|
|
||||||
func (gui *Gui) handleCopySelectedSideContextItemToClipboard() error {
|
func (gui *Gui) handleCopySelectedSideContextItemToClipboard() error {
|
||||||
return gui.handleCopySelectedSideContextItemToClipboardWithTruncation(-1)
|
return gui.handleCopySelectedSideContextItemToClipboardWithTruncation(-1)
|
||||||
}
|
}
|
||||||
|
@@ -248,12 +248,6 @@ func (self *Gui) GetInitialKeybindings() ([]*types.Binding, []*gocui.ViewMouseBi
|
|||||||
Modifier: gocui.ModNone,
|
Modifier: gocui.ModNone,
|
||||||
Handler: self.scrollDownConfirmationPanel,
|
Handler: self.scrollDownConfirmationPanel,
|
||||||
},
|
},
|
||||||
{
|
|
||||||
ViewName: "confirmation",
|
|
||||||
Key: gocui.MouseLeft,
|
|
||||||
Modifier: gocui.ModNone,
|
|
||||||
Handler: self.handleConfirmationClick,
|
|
||||||
},
|
|
||||||
{
|
{
|
||||||
ViewName: "confirmation",
|
ViewName: "confirmation",
|
||||||
Key: gocui.MouseWheelUp,
|
Key: gocui.MouseWheelUp,
|
||||||
|
Reference in New Issue
Block a user