mirror of
https://github.com/JanDeDobbeleer/oh-my-posh.git
synced 2024-12-27 20:09:39 -08:00
parent
edb3842db7
commit
2b576a3cce
|
@ -403,15 +403,23 @@ func (w *Writer) writeColorOverrides(match map[string]string, background string,
|
|||
if position == len(w.runes)-1 {
|
||||
return
|
||||
}
|
||||
if w.currentBackground != w.background || w.transparent {
|
||||
if w.transparent {
|
||||
w.writeEscapedAnsiString(transparentEnd)
|
||||
}
|
||||
|
||||
if w.transparent {
|
||||
w.writeEscapedAnsiString(transparentEnd)
|
||||
}
|
||||
|
||||
if w.background.IsClear() {
|
||||
w.writeEscapedAnsiString(colorStyle.End)
|
||||
}
|
||||
|
||||
if w.currentBackground != w.background && !w.background.IsClear() {
|
||||
w.writeEscapedAnsiString(fmt.Sprintf(colorise, w.background))
|
||||
}
|
||||
if w.currentForeground != w.foreground || w.transparent {
|
||||
|
||||
if (w.currentForeground != w.foreground || w.transparent) && !w.foreground.IsClear() {
|
||||
w.writeEscapedAnsiString(fmt.Sprintf(colorise, w.foreground))
|
||||
}
|
||||
|
||||
w.transparent = false
|
||||
return
|
||||
}
|
||||
|
|
|
@ -26,7 +26,7 @@ func TestWriteANSIColors(t *testing.T) {
|
|||
{
|
||||
Case: "Bold with color override",
|
||||
Input: "<b><#ffffff>test</></b>",
|
||||
Expected: "\x1b[1m\x1b[30m\x1b[38;2;255;255;255mtest\x1b[30m\x1b[22m\x1b[0m",
|
||||
Expected: "\x1b[1m\x1b[30m\x1b[38;2;255;255;255mtest\x1b[0m\x1b[30m\x1b[22m\x1b[0m",
|
||||
Colors: &cachedColor{Foreground: "black", Background: ParentBackground},
|
||||
},
|
||||
{
|
||||
|
|
|
@ -36,6 +36,10 @@ func (c Color) IsTransparent() bool {
|
|||
return c == transparentColor
|
||||
}
|
||||
|
||||
func (c Color) IsClear() bool {
|
||||
return c == transparentColor || c == emptyColor
|
||||
}
|
||||
|
||||
func (c Color) ToForeground() Color {
|
||||
colorString := string(c)
|
||||
if strings.HasPrefix(colorString, "38;") {
|
||||
|
|
Loading…
Reference in a new issue