summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJunegunn Choi <junegunn.c@gmail.com>2021-04-06 00:51:39 +0900
committerJunegunn Choi <junegunn.c@gmail.com>2021-04-06 00:51:39 +0900
commitbe36de2482fd68d62abb3eac217ac7d8edecdb92 (patch)
treeba0f160228e3b6396036f74fa099952d6fc7045d
parent391237f7df7de77915786bd7bfd5b936d9df3b56 (diff)
Ignore more ANSI escape sequences
Fix #2420
-rw-r--r--src/ansi.go10
1 files changed, 5 insertions, 5 deletions
diff --git a/src/ansi.go b/src/ansi.go
index a67ac0b9..698bf89e 100644
--- a/src/ansi.go
+++ b/src/ansi.go
@@ -103,11 +103,11 @@ func matchOperatingSystemCommand(s string) int {
}
func matchControlSequence(s string) int {
- // `\x1b[\\[()][0-9;]*[a-zA-Z@]`
- // ^ match starting here
+ // `\x1b[\\[()][0-9;?]*[a-zA-Z@]`
+ // ^ match starting here
//
i := 2 // prefix matched in nextAnsiEscapeSequence()
- for ; i < len(s) && (isNumeric(s[i]) || s[i] == ';'); i++ {
+ for ; i < len(s) && (isNumeric(s[i]) || s[i] == ';' || s[i] == '?'); i++ {
}
if i < len(s) {
c := s[i]
@@ -125,7 +125,7 @@ func isCtrlSeqStart(c uint8) bool {
// nextAnsiEscapeSequence returns the ANSI escape sequence and is equivalent to
// calling FindStringIndex() on the below regex (which was originally used):
//
-// "(?:\x1b[\\[()][0-9;]*[a-zA-Z@]|\x1b][0-9];[[:print:]]+(?:\x1b\\\\|\x07)|\x1b.|[\x0e\x0f]|.\x08)"
+// "(?:\x1b[\\[()][0-9;?]*[a-zA-Z@]|\x1b][0-9];[[:print:]]+(?:\x1b\\\\|\x07)|\x1b.|[\x0e\x0f]|.\x08)"
//
func nextAnsiEscapeSequence(s string) (int, int) {
// fast check for ANSI escape sequences
@@ -154,7 +154,7 @@ Loop:
return i - n, i + 1
}
case '\x1b':
- // match: `\x1b[\\[()][0-9;]*[a-zA-Z@]`
+ // match: `\x1b[\\[()][0-9;?]*[a-zA-Z@]`
if i+2 < len(s) && isCtrlSeqStart(s[i+1]) {
if j := matchControlSequence(s[i:]); j != -1 {
return i, i + j