Skip to content
Snippets Groups Projects
Commit 9d138173 authored by Junegunn Choi's avatar Junegunn Choi
Browse files

Fix #155 - Empty ANSI color code to reset color state

parent eae53576
No related branches found
No related tags found
No related merge requests found
......@@ -99,6 +99,9 @@ func interpretCode(ansiCode string, prevState *ansiState) *ansiState {
}
ansiCode = ansiCode[2 : len(ansiCode)-1]
if len(ansiCode) == 0 {
init()
}
for _, code := range strings.Split(ansiCode, ";") {
if num, err := strconv.Atoi(code); err == nil {
switch state256 {
......
......@@ -45,6 +45,14 @@ func TestExtractColor(t *testing.T) {
assert(offsets[0], 0, 11, -1, -1, true)
})
src = "\x1b[1mhello \x1b[mworld"
check(func(offsets []ansiOffset) {
if len(offsets) != 1 {
t.Fail()
}
assert(offsets[0], 0, 6, -1, -1, true)
})
src = "hello \x1b[34;45;1mworld"
check(func(offsets []ansiOffset) {
if len(offsets) != 1 {
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment