diff --git a/pkg/utils/color.go b/pkg/utils/color.go index a4ad578e0..05e0aa9bc 100644 --- a/pkg/utils/color.go +++ b/pkg/utils/color.go @@ -25,7 +25,9 @@ func Decolorise(str string) string { } re := regexp.MustCompile(`\x1B\[([0-9]{1,3}(;[0-9]{1,3})*)?[mGK]`) + linkRe := regexp.MustCompile(`\x1B]8;[^;]*;(.*?)(\x1B.|\x07)`) ret := re.ReplaceAllString(str, "") + ret = linkRe.ReplaceAllString(ret, "") decoloriseMutex.Lock() decoloriseCache[str] = ret diff --git a/pkg/utils/color_test.go b/pkg/utils/color_test.go index 1440f946c..19770d63e 100644 --- a/pkg/utils/color_test.go +++ b/pkg/utils/color_test.go @@ -2,6 +2,8 @@ package utils import ( "testing" + + "github.com/jesseduffield/lazygit/pkg/gui/style" ) func TestDecolorise(t *testing.T) { @@ -189,6 +191,10 @@ func TestDecolorise(t *testing.T) { input: "\x1b[38;2;157;205;18mta\x1b[0m", output: "ta", }, + { + input: "a_" + style.PrintSimpleHyperlink("xyz") + "_b", + output: "a_xyz_b", + }, } for _, test := range tests {