diff --git a/colors.go b/colors.go index 69c5bb14..54e5b21b 100644 --- a/colors.go +++ b/colors.go @@ -103,8 +103,8 @@ func applyAnsiCodes(s string, st tcell.Style) tcell.Style { // Probably because this is used for previewers too tokslen := len(toks) for i := 0; i < tokslen; i++ { - switch toks[i] { - case "", "0": + switch strings.TrimLeft(toks[i], "0") { + case "": st = tcell.StyleDefault case "1": st = st.Bold(true) diff --git a/colors_test.go b/colors_test.go index e7e62e17..8085ce13 100644 --- a/colors_test.go +++ b/colors_test.go @@ -53,6 +53,9 @@ func TestApplyAnsiCodes(t *testing.T) { {"1;31", none, none.Foreground(tcell.ColorMaroon).Bold(true)}, {"1;31", none.Foreground(tcell.ColorGreen), none.Foreground(tcell.ColorMaroon).Bold(true)}, + {"01;31", none, none.Foreground(tcell.ColorMaroon).Bold(true)}, + {"01;31", none.Foreground(tcell.ColorGreen), none.Foreground(tcell.ColorMaroon).Bold(true)}, + {"38;5;0", none, none.Foreground(tcell.ColorBlack)}, {"38;5;1", none, none.Foreground(tcell.ColorMaroon)}, {"38;5;8", none, none.Foreground(tcell.ColorGray)},