Handle leading zeros in SGR escape sequences (#1912)
This commit is contained in:
1 parent
7797ad695f
commit
74b2954e6a
2 files changed
+5
-2
No files matched your search
@@ -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)
|
||||
|
||||
@@ -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)},
|
||||
|
||||
Reference in new issue
Block a user