summaryrefslogtreecommitdiff
path: root/src/ansi.go
diff options
context:
space:
mode:
authorJunegunn Choi <junegunn.c@gmail.com>2023-12-25 17:05:14 +0900
committerJunegunn Choi <junegunn.c@gmail.com>2023-12-25 17:05:54 +0900
commit0e999482cb13c194427d47687a49473e1e240a20 (patch)
tree1a39060af647ffbd64539be3e920e9fd46a5f41e /src/ansi.go
parent65b2c060274c7735e6b1e0e5b924d057641f2e4a (diff)
downloadfzf-0e999482cb13c194427d47687a49473e1e240a20.tar.gz
Fix handling of empty ANSI color sequence
Fix #3320
Diffstat (limited to 'src/ansi.go')
-rw-r--r--src/ansi.go9
1 files changed, 9 insertions, 0 deletions
diff --git a/src/ansi.go b/src/ansi.go
index 05e08613..e917a4f2 100644
--- a/src/ansi.go
+++ b/src/ansi.go
@@ -351,9 +351,11 @@ func interpretCode(ansiCode string, prevState *ansiState) ansiState {
ptr := &state.fg
var delimiter byte = 0
+ count := 0
for len(ansiCode) != 0 {
var num int
if num, delimiter, ansiCode = parseAnsiCode(ansiCode, delimiter); num != -1 {
+ count++
switch state256 {
case 0:
switch num {
@@ -435,6 +437,13 @@ func interpretCode(ansiCode string, prevState *ansiState) ansiState {
}
}
+ // Empty sequence: reset
+ if count == 0 {
+ state.fg = -1
+ state.bg = -1
+ state.attr = 0
+ }
+
if state256 > 0 {
*ptr = -1
}