Refactor AsColor change to have catch-all default to pass test suite

mine
Gavin 2019-12-16 14:06:12 -05:00
parent b8b3c9dc83
commit 6c8f6f4424
1 changed files with 4 additions and 6 deletions

View File

@ -327,12 +327,10 @@ func (s *Styles) Update() {
// AsColor checks color index, if match return color otherwise pink it is. // AsColor checks color index, if match return color otherwise pink it is.
func AsColor(c string) tcell.Color { func AsColor(c string) tcell.Color {
if color, ok := tcell.ColorNames[c]; ok {
return color
} else {
// Use tcell.GetColor to support hex codes. // Use tcell.GetColor to support hex codes.
// "Creates a Color from a color name (W3C name). A hex value may be supplied as a string in the format "#ffffff"." // "Creates a Color from a color name (W3C name). A hex value may be supplied as a string in the format "#ffffff"."
color := tcell.GetColor(c) if color := tcell.GetColor(c); color != -1 {
return color return color
} }
return tcell.ColorPink
} }