mirror of
https://github.com/JanDeDobbeleer/oh-my-posh.git
synced 2024-12-27 11:59:40 -08:00
parent
cc3a64fad2
commit
8452b5b1e4
|
@ -409,6 +409,12 @@ func (w *Writer) writeColorOverrides(match map[string]string, background string,
|
|||
if match[ANCHOR] == colorStyle.AnchorEnd {
|
||||
// make sure to reset the colors if needed
|
||||
position += len([]rune(colorStyle.AnchorEnd)) - 1
|
||||
|
||||
// do not reset when colors are identical
|
||||
if w.currentBackground == w.background && w.currentForeground == w.foreground {
|
||||
return
|
||||
}
|
||||
|
||||
// do not restore colors at the end of the string, we print it anyways
|
||||
if position == len(w.runes)-1 {
|
||||
return
|
||||
|
|
|
@ -17,6 +17,12 @@ func TestWriteANSIColors(t *testing.T) {
|
|||
Parent *Colors
|
||||
TerminalBackground string
|
||||
}{
|
||||
{
|
||||
Case: "Inline override identical",
|
||||
Input: "\ue0a0saturnay <red>↑</>1",
|
||||
Expected: "\x1b[31m\ue0a0saturnay ↑1\x1b[0m",
|
||||
Colors: &Colors{Foreground: "red", Background: Transparent},
|
||||
},
|
||||
{
|
||||
Case: "Bold",
|
||||
Input: "<b>test</b>",
|
||||
|
|
Loading…
Reference in a new issue