fix(ansi): append remaining hyperlink

resolves #3323
This commit is contained in:
Jan De Dobbeleer 2023-01-06 13:46:19 +01:00 committed by Jan De Dobbeleer
parent 2b576a3cce
commit 85897ce9ec
2 changed files with 6 additions and 0 deletions

View file

@ -324,6 +324,11 @@ func (w *Writer) Write(background, foreground, text string) {
w.write(i, s)
}
// append remnant hyperlink
w.builder.WriteString(w.hyperlinkBuilder.String())
w.hyperlinkBuilder.Reset()
// reset colors
w.writeEscapedAnsiString(colorStyle.End)
// reset current

View file

@ -17,6 +17,7 @@ func TestGenerateHyperlinkNoUrl(t *testing.T) {
{Text: "sample text with no url", ShellName: shell.ZSH, Expected: "%{\x1b[47m%}%{\x1b[30m%}sample text with no url%{\x1b[0m%}"},
{Text: "sample text with no url", ShellName: shell.PWSH, Expected: "\x1b[47m\x1b[30msample text with no url\x1b[0m"},
{Text: "sample text with no url", ShellName: shell.BASH, Expected: "\\[\x1b[47m\\]\\[\x1b[30m\\]sample text with no url\\[\x1b[0m\\]"},
{Text: "sample text with no url [test]", ShellName: shell.BASH, Expected: "\\[\x1b[47m\\]\\[\x1b[30m\\]sample text with no url [test]\\[\x1b[0m\\]"},
}
for _, tc := range cases {
a := Writer{