mirror of
https://github.com/Llewellynvdm/fzf.git
synced 2024-11-22 21:05:09 +00:00
Fix #370 - Panic when trying to set colors when colors are disabled
This commit is contained in:
parent
1da065e50e
commit
a4eb3323da
@ -380,8 +380,11 @@ func parseTiebreak(str string) tiebreak {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func dupeTheme(theme *curses.ColorTheme) *curses.ColorTheme {
|
func dupeTheme(theme *curses.ColorTheme) *curses.ColorTheme {
|
||||||
dupe := *theme
|
if theme != nil {
|
||||||
return &dupe
|
dupe := *theme
|
||||||
|
return &dupe
|
||||||
|
}
|
||||||
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func parseTheme(defaultTheme *curses.ColorTheme, str string) *curses.ColorTheme {
|
func parseTheme(defaultTheme *curses.ColorTheme, str string) *curses.ColorTheme {
|
||||||
@ -402,7 +405,7 @@ func parseTheme(defaultTheme *curses.ColorTheme, str string) *curses.ColorTheme
|
|||||||
}
|
}
|
||||||
// Color is disabled
|
// Color is disabled
|
||||||
if theme == nil {
|
if theme == nil {
|
||||||
errorExit("colors disabled; cannot customize colors")
|
continue
|
||||||
}
|
}
|
||||||
|
|
||||||
pair := strings.Split(str, ":")
|
pair := strings.Split(str, ":")
|
||||||
|
@ -316,3 +316,15 @@ func TestColorSpec(t *testing.T) {
|
|||||||
t.Errorf("using default colors")
|
t.Errorf("using default colors")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func TestParseNilTheme(t *testing.T) {
|
||||||
|
var theme *curses.ColorTheme
|
||||||
|
newTheme := parseTheme(theme, "prompt:12")
|
||||||
|
if newTheme != nil {
|
||||||
|
t.Errorf("color is disabled. keep it that way.")
|
||||||
|
}
|
||||||
|
newTheme = parseTheme(theme, "prompt:12,dark,prompt:13")
|
||||||
|
if newTheme.Prompt != 13 {
|
||||||
|
t.Errorf("color should now be enabled and customized")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user