Fix segmentation fault on \x1b[0K

Fix #2339
This commit is contained in:
Junegunn Choi 2021-02-01 22:59:11 +09:00
parent a0649edc1e
commit 1cfeec0ca3
No known key found for this signature in database
GPG Key ID: 254BC280FEF9C627

View File

@ -201,7 +201,7 @@ func interpretCode(ansiCode string, prevState *ansiState) *ansiState {
state = &ansiState{prevState.fg, prevState.bg, prevState.attr, prevState.lbg}
}
if ansiCode[0] != '\x1b' || ansiCode[1] != '[' || ansiCode[len(ansiCode)-1] != 'm' {
if strings.HasSuffix(ansiCode, "0K") {
if strings.HasSuffix(ansiCode, "0K") && prevState != nil {
state.lbg = prevState.bg
}
return state