mirror of
https://github.com/JanDeDobbeleer/oh-my-posh.git
synced 2024-12-27 03:49:40 -08:00
fix: inherit Transparent when no parent
This commit is contained in:
parent
631aace7a8
commit
eca24bebcc
|
@ -137,9 +137,15 @@ func (a *AnsiColor) write(background, foreground, text string) {
|
|||
if background == Inherit && a.Parent != nil {
|
||||
background = a.Parent.Background
|
||||
}
|
||||
if background == Inherit && a.Parent == nil {
|
||||
background = Transparent
|
||||
}
|
||||
if foreground == Inherit && a.Parent != nil {
|
||||
foreground = a.Parent.Foreground
|
||||
}
|
||||
if foreground == Inherit && a.Parent == nil {
|
||||
foreground = Transparent
|
||||
}
|
||||
inverted := foreground == Transparent && len(background) != 0
|
||||
background = a.getAnsiFromColorString(background, !inverted)
|
||||
foreground = a.getAnsiFromColorString(foreground, false)
|
||||
|
|
|
@ -92,6 +92,18 @@ func TestWriteANSIColors(t *testing.T) {
|
|||
Colors: &Color{Foreground: "black", Background: "white"},
|
||||
Parent: &Color{Foreground: "yellow", Background: "red"},
|
||||
},
|
||||
{
|
||||
Case: "Inherit no parent foreground",
|
||||
Input: "hello <inherit>world</>",
|
||||
Expected: "\x1b[47m\x1b[30mhello \x1b[0m\x1b[47;49m\x1b[7mworld\x1b[0m",
|
||||
Colors: &Color{Foreground: "black", Background: "white"},
|
||||
},
|
||||
{
|
||||
Case: "Inherit no parent background",
|
||||
Input: "hello <,inherit>world</>",
|
||||
Expected: "\x1b[47m\x1b[30mhello \x1b[0m\x1b[30mworld\x1b[0m",
|
||||
Colors: &Color{Foreground: "black", Background: "white"},
|
||||
},
|
||||
{
|
||||
Case: "Inline override",
|
||||
Input: "hello, <red>world</>, rabbit",
|
||||
|
|
|
@ -12,7 +12,7 @@ func (az *azfunc) init(props *properties, env environmentInfo) {
|
|||
az.language = &language{
|
||||
env: env,
|
||||
props: props,
|
||||
extensions: []string{"host.json", "local.settings.json"},
|
||||
extensions: []string{"host.json", "local.settings.json", "function.json"},
|
||||
commands: []*cmd{
|
||||
{
|
||||
executable: "func",
|
||||
|
|
Loading…
Reference in a new issue