Trim unsupported OSC sequences (#4169)

Fix #4169
This commit is contained in:
Junegunn Choi
2025-01-10 20:53:47 +09:00
parent d7b13f3408
commit bd3e65df4d
2 changed files with 28 additions and 12 deletions

View File

@@ -337,17 +337,25 @@ func TestExtractColor(t *testing.T) {
})
state = nil
var color24 tui.Color = (1 << 24) + (180 << 16) + (190 << 8) + 254
src = "\x1b[1mhello \x1b[22;1;38:2:180:190:254mworld"
check(func(offsets *[]ansiOffset, state *ansiState) {
if len(*offsets) != 2 {
t.Fail()
}
var color tui.Color = (1 << 24) + (180 << 16) + (190 << 8) + 254
if state.fg != color || state.attr != 1 {
if state.fg != color24 || state.attr != 1 {
t.Fail()
}
assert((*offsets)[0], 0, 6, -1, -1, true)
assert((*offsets)[1], 6, 11, color, -1, true)
assert((*offsets)[1], 6, 11, color24, -1, true)
})
src = "\x1b]133;A\x1b\\hello \x1b]133;C\x1b\\world"
check(func(offsets *[]ansiOffset, state *ansiState) {
if len(*offsets) != 1 {
t.Fail()
}
assert((*offsets)[0], 0, 11, color24, -1, true)
})
}