mirror of
https://github.com/taigrr/bubbletea.git
synced 2026-04-02 02:59:09 -07:00
fix(key): support very long buffered input (#570)
This commit is contained in:
committed by
GitHub
parent
6d07f4a410
commit
5536bca34e
21
key_test.go
21
key_test.go
@@ -200,7 +200,7 @@ func TestDetectOneMsg(t *testing.T) {
|
||||
|
||||
for _, tc := range td {
|
||||
t.Run(fmt.Sprintf("%q", string(tc.seq)), func(t *testing.T) {
|
||||
width, msg := detectOneMsg(tc.seq)
|
||||
width, msg := detectOneMsg(tc.seq, false /* canHaveMoreData */)
|
||||
if width != len(tc.seq) {
|
||||
t.Errorf("parser did not consume the entire input: got %d, expected %d", width, len(tc.seq))
|
||||
}
|
||||
@@ -211,6 +211,25 @@ func TestDetectOneMsg(t *testing.T) {
|
||||
}
|
||||
}
|
||||
|
||||
func TestReadLongInput(t *testing.T) {
|
||||
input := strings.Repeat("a", 1000)
|
||||
msgs := testReadInputs(t, bytes.NewReader([]byte(input)))
|
||||
if len(msgs) != 1 {
|
||||
t.Errorf("expected 1 messages, got %d", len(msgs))
|
||||
}
|
||||
km := msgs[0]
|
||||
k := Key(km.(KeyMsg))
|
||||
if k.Type != KeyRunes {
|
||||
t.Errorf("expected key runes, got %d", k.Type)
|
||||
}
|
||||
if len(k.Runes) != 1000 || !reflect.DeepEqual(k.Runes, []rune(input)) {
|
||||
t.Errorf("unexpected runes: %+v", k)
|
||||
}
|
||||
if k.Alt {
|
||||
t.Errorf("unexpected alt")
|
||||
}
|
||||
}
|
||||
|
||||
func TestReadInput(t *testing.T) {
|
||||
type test struct {
|
||||
keyname string
|
||||
|
||||
Reference in New Issue
Block a user