zot/packages/tui/editor_shift_enter_test.go
patriceckhart 94ece7d00e
Some checks are pending
ci / test (macos-latest) (push) Waiting to run
ci / test (ubuntu-latest) (push) Waiting to run
ci / test (windows-latest) (push) Waiting to run
Support Shift-Enter in terminal input
2026-06-15 18:54:26 +02:00

24 lines
635 B
Go

package tui
import "testing"
func TestEditorShiftEnterInsertsNewline(t *testing.T) {
e := NewEditor("> ")
e.HandleKey(Key{Kind: KeyRune, Rune: 'a'})
if submit := e.HandleKey(Key{Kind: KeyEnter, Shift: true}); submit {
t.Fatal("Shift+Enter submitted; want newline")
}
e.HandleKey(Key{Kind: KeyRune, Rune: 'b'})
if got, want := e.Value(), "a\nb"; got != want {
t.Fatalf("Value() = %q, want %q", got, want)
}
}
func TestEditorPlainEnterSubmits(t *testing.T) {
e := NewEditor("> ")
e.HandleKey(Key{Kind: KeyRune, Rune: 'a'})
if submit := e.HandleKey(Key{Kind: KeyEnter}); !submit {
t.Fatal("Enter did not submit")
}
}