|
if r[pos] == '\033' && r[pos+1] == '[' { |
- This line will panic with runtime error: index out of range if the last character in the rune buffer is \033 the escape sequence.
- The other potential bug is that not necessarily we need to escape the entire sequence up until "m", because it could be an invalid color code and the "m" is not part of the color code.
For the panic, need to check if \033 is the last character in the sequence, if it is, ignore it and return the sequence. For more robust solution we could use a buffer to buffer the ANSI color codes, but this might not guarantee correctness.
readline/internal/runes/runes.go
Line 117 in 16c2b71
For the panic, need to check if \033 is the last character in the sequence, if it is, ignore it and return the sequence. For more robust solution we could use a buffer to buffer the ANSI color codes, but this might not guarantee correctness.