mirror of
https://github.com/JanDeDobbeleer/oh-my-posh.git
synced 2025-03-05 20:49:04 -08:00
fix(ansi): reset background when transparent
This commit is contained in:
parent
517b7a6d57
commit
099f6cb6c3
|
@ -558,7 +558,12 @@ func (w *Writer) endColorOverride(position int) int {
|
||||||
}
|
}
|
||||||
|
|
||||||
if previousBg != bg {
|
if previousBg != bg {
|
||||||
w.writeEscapedAnsiString(fmt.Sprintf(colorise, previousBg))
|
background := fmt.Sprintf(colorise, previousBg)
|
||||||
|
if previousBg.IsClear() {
|
||||||
|
background = backgroundStyle.End
|
||||||
|
}
|
||||||
|
|
||||||
|
w.writeEscapedAnsiString(background)
|
||||||
}
|
}
|
||||||
|
|
||||||
if previousFg != fg {
|
if previousFg != fg {
|
||||||
|
|
|
@ -212,6 +212,12 @@ func TestWriteANSIColors(t *testing.T) {
|
||||||
Expected: "\x1b[47m\x1b[31m<\x1b[30m>\x1b[33m<\x1b[0m",
|
Expected: "\x1b[47m\x1b[31m<\x1b[30m>\x1b[33m<\x1b[0m",
|
||||||
Colors: &Colors{Foreground: "black", Background: "white"},
|
Colors: &Colors{Foreground: "black", Background: "white"},
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
Case: "Transparent override with parent",
|
||||||
|
Input: "hello <#011627,#82AAFF>new</> world",
|
||||||
|
Expected: "\x1b[33mhello \x1b[48;2;130;170;255m\x1b[38;2;1;22;39mnew\x1b[49m\x1b[33m world\x1b[0m",
|
||||||
|
Colors: &Colors{Foreground: "yellow", Background: "transparent"},
|
||||||
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
for _, tc := range cases {
|
for _, tc := range cases {
|
||||||
|
|
Loading…
Reference in a new issue