mirror of
https://github.com/taigrr/bubbletea.git
synced 2026-04-02 02:59:09 -07:00
fix: properly skip over unrecognized CSI sequences.
This commit is contained in:
committed by
Christian Muehlhaeuser
parent
d20732aaea
commit
b074f6f5a4
6
key.go
6
key.go
@@ -624,6 +624,12 @@ func readInputs(input io.Reader) ([]Msg, error) {
|
|||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Is this an unrecognized CSI sequence? If so, ignore it.
|
||||||
|
if len(runes) > 2 && runes[0] == 0x1b && (runes[1] == '[' ||
|
||||||
|
(len(runes) > 3 && runes[1] == 0x1b && runes[2] == '[')) {
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
|
||||||
// Is the alt key pressed? If so, the buffer will be prefixed with an
|
// Is the alt key pressed? If so, the buffer will be prefixed with an
|
||||||
// escape.
|
// escape.
|
||||||
alt := false
|
alt := false
|
||||||
|
|||||||
@@ -152,6 +152,10 @@ func TestReadInput(t *testing.T) {
|
|||||||
},
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
"unrecognized": {
|
||||||
|
[]byte{'\x1b', '[', '-', '-', '-', '-', 'X'},
|
||||||
|
[]Msg{},
|
||||||
|
},
|
||||||
} {
|
} {
|
||||||
t.Run(out, func(t *testing.T) {
|
t.Run(out, func(t *testing.T) {
|
||||||
msgs, err := readInputs(bytes.NewReader(td.in))
|
msgs, err := readInputs(bytes.NewReader(td.in))
|
||||||
|
|||||||
Reference in New Issue
Block a user