fix(ui): menu deboucing (#14)

Fixed menu keep moving/debouncing while move up/down
This commit is contained in:
VERSE
2026-07-02 15:41:44 +07:00
committed by GitHub
parent f37f0681ce
commit c7960aac46
3 changed files with 241 additions and 74 deletions
+50
View File
@@ -0,0 +1,50 @@
package tests
import (
"testing"
"github.com/versenilvis/iris/integration"
)
func TestComputeCursorCol(t *testing.T) {
tests := []struct {
name string
data []byte
want int
}{
{
name: "Simple prompt",
data: []byte("λ "),
want: 2,
},
{
name: "ANSI color prompt",
data: []byte("\033[32mλ \033[0m"),
want: 2,
},
{
name: "Carriage return and move right",
data: []byte("λ \033[140G...22 chars right prompt...\r\033[2C"),
want: 2,
},
{
name: "OSC sequence before prompt",
data: []byte("\033]0;iris on fix/menu-debouncing\007λ "),
want: 2,
},
{
name: "CSI Horizontal Absolute",
data: []byte("abc\033[10Gde"),
want: 11,
},
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
got := integration.ComputeCursorCol(tt.data)
if got != tt.want {
t.Errorf("ComputeCursorCol(%q) = %d, want %d", tt.data, got, tt.want)
}
})
}
}