mirror of
https://github.com/fish-shell/fish-shell.git
synced 2026-05-30 19:41:15 -03:00
Fix accidental truncation of raw sequences
For numpad 1 with nulock, Alacritty sends
escape,[,5,7,4,0,0,u
which is codepoint \x31, key "1". We have a terminfo mapping for "sright"
which translates to
escape,[,1,;,2,C
The first two characters, escape and [ match. Then we accidentally match the
"1" from the mapping against the entire sequence, because that sequence is
canonicalized to codepoint "1" . The most blatant problem is that we discard
the rest of the sequence. Fix that.
This allows us to re-enable raw CSI u mappings like "bind \e[1u ..."
which is what kitty uses for shell integration.
This commit is contained in:
@@ -616,6 +616,7 @@ fn new(event_queue: &mut Inputter) -> EventQueuePeeker {
|
||||
|
||||
/// \return the next event.
|
||||
fn next(&mut self) -> CharEvent {
|
||||
assert!(self.subidx == 0);
|
||||
assert!(
|
||||
self.idx <= self.peeked.len(),
|
||||
"Index must not be larger than dequeued event count"
|
||||
@@ -660,16 +661,12 @@ fn next_is_char(&mut self, key: Key, escaped: bool) -> bool {
|
||||
let Some(kevt) = evt.get_key() else {
|
||||
return false;
|
||||
};
|
||||
if kevt.key == key {
|
||||
if self.subidx == 0 && kevt.key == key {
|
||||
self.idx += 1;
|
||||
self.subidx = 0;
|
||||
return true;
|
||||
}
|
||||
let actual_seq = kevt.seq.as_char_slice();
|
||||
let is_csi_u = actual_seq.get(0) == Some(&'\x1b')
|
||||
&& actual_seq.get(1) == Some(&'[')
|
||||
&& actual_seq.last() == Some(&'u');
|
||||
if !actual_seq.is_empty() && !is_csi_u {
|
||||
if !actual_seq.is_empty() {
|
||||
let seq_char = actual_seq[self.subidx];
|
||||
if Key::from_single_char(seq_char) == key {
|
||||
self.subidx += 1;
|
||||
|
||||
Reference in New Issue
Block a user