mirror of
https://github.com/JanDeDobbeleer/oh-my-posh.git
synced 2025-01-30 12:32:22 -08:00
parent
336f351b98
commit
52f4ae662d
|
@ -144,14 +144,15 @@ func (a *Ansi) GenerateHyperlink(text string) string {
|
||||||
var buffer strings.Builder
|
var buffer strings.Builder
|
||||||
var part string
|
var part string
|
||||||
for i := range parts {
|
for i := range parts {
|
||||||
|
part += parts[i]
|
||||||
if strings.Contains(parts[i], "[") && !strings.Contains(parts[i], "]") {
|
if strings.Contains(parts[i], "[") && !strings.Contains(parts[i], "]") {
|
||||||
part += parts[i]
|
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
part += parts[i]
|
|
||||||
buffer.WriteString(a.replaceHyperlink(part))
|
buffer.WriteString(a.replaceHyperlink(part))
|
||||||
part = ""
|
part = ""
|
||||||
}
|
}
|
||||||
|
// when we did not process any parts, we return the original text
|
||||||
|
buffer.WriteString(part)
|
||||||
return buffer.String()
|
return buffer.String()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -31,6 +31,11 @@ func TestGenerateHyperlinkWithUrl(t *testing.T) {
|
||||||
ShellName string
|
ShellName string
|
||||||
Expected string
|
Expected string
|
||||||
}{
|
}{
|
||||||
|
{
|
||||||
|
Text: "in <accent>\x1b[1mpwsh \x1b[22m</> ",
|
||||||
|
ShellName: shell.PWSH,
|
||||||
|
Expected: "in <accent>\x1b[1mpwsh \x1b[22m</> ",
|
||||||
|
},
|
||||||
{
|
{
|
||||||
Text: "[google](http://www.google.be) [maps (2/2)](http://maps.google.be)",
|
Text: "[google](http://www.google.be) [maps (2/2)](http://maps.google.be)",
|
||||||
ShellName: shell.FISH,
|
ShellName: shell.FISH,
|
||||||
|
|
Loading…
Reference in a new issue