mirror of
https://github.com/jesseduffield/lazygit.git
synced 2025-08-09 09:22:48 +03:00
Use our new hyperlink support in confirmations
This commit is contained in:
@@ -259,11 +259,7 @@ func underlineLinks(text string) string {
|
||||
} else {
|
||||
linkEnd += linkStart
|
||||
}
|
||||
underlinedLink := style.AttrUnderline.Sprint(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"
|
||||
}
|
||||
underlinedLink := style.PrintSimpleHyperlink(remaining[linkStart:linkEnd])
|
||||
result += remaining[:linkStart] + underlinedLink
|
||||
remaining = remaining[linkEnd:]
|
||||
}
|
||||
|
@@ -27,27 +27,27 @@ func Test_underlineLinks(t *testing.T) {
|
||||
{
|
||||
name: "entire string is a link",
|
||||
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",
|
||||
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",
|
||||
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",
|
||||
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",
|
||||
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
|
||||
}
|
||||
|
||||
func (gui *Gui) handleConfirmationClick() error {
|
||||
if gui.Views.Confirmation.Editable {
|
||||
return nil
|
||||
}
|
||||
|
||||
return gui.handleGenericClick(gui.Views.Confirmation)
|
||||
}
|
||||
|
||||
func (gui *Gui) handleCopySelectedSideContextItemToClipboard() error {
|
||||
return gui.handleCopySelectedSideContextItemToClipboardWithTruncation(-1)
|
||||
}
|
||||
|
@@ -248,12 +248,6 @@ func (self *Gui) GetInitialKeybindings() ([]*types.Binding, []*gocui.ViewMouseBi
|
||||
Modifier: gocui.ModNone,
|
||||
Handler: self.scrollDownConfirmationPanel,
|
||||
},
|
||||
{
|
||||
ViewName: "confirmation",
|
||||
Key: gocui.MouseLeft,
|
||||
Modifier: gocui.ModNone,
|
||||
Handler: self.handleConfirmationClick,
|
||||
},
|
||||
{
|
||||
ViewName: "confirmation",
|
||||
Key: gocui.MouseWheelUp,
|
||||
|
Reference in New Issue
Block a user