Also ignore invalid recursive escape sequences

We parse "\e\e[x" as alt-modified "Invalid" key.  Due to this extra
modifier, we accidentally add it to the input queue, instead of
dropping this invalid key.

We don't really want to try to extract some valid keys from this
invalid sequence, see also the parent commit.

This allows us to remove misplaced validation that was added by
e8e91c97a6 (fish_key_reader: ignore sentinel key, 2024-04-02) but
later obsoleted by 66c6e89f98 (Don't add collateral sentinel key to
input queue, 2024-04-03).
This commit is contained in:
Johannes Altmanninger
2024-12-30 08:12:32 +01:00
parent 3201cb9f01
commit 84f19a931d
3 changed files with 7 additions and 6 deletions

View File

@@ -23,7 +23,7 @@
terminal_protocol_hacks, terminal_protocols_enable_ifn, CharEvent, InputEventQueue,
InputEventQueuer,
},
key::{self, char_to_symbol, Key},
key::{char_to_symbol, Key},
panic::panic_handler,
print_help::print_help,
printf,
@@ -101,9 +101,6 @@ fn process_input(continuous_mode: bool, verbose: bool) -> i32 {
continue;
};
let c = kevt.key.codepoint;
if c == key::Invalid {
continue;
}
if verbose {
printf!("# decoded from: ");
for byte in kevt.seq.chars() {

View File

@@ -679,6 +679,7 @@ fn try_readch(&mut self, blocking: bool) -> Option<CharEvent> {
if key == Some(Key::from_raw(key::Invalid)) {
continue;
}
assert!(key.map_or(true, |key| key.codepoint != key::Invalid));
let mut consumed = 0;
let mut state = zero_mbstate();
let mut i = 0;
@@ -778,10 +779,13 @@ fn parse_escape_sequence(
return Some(
match self.parse_escape_sequence(buffer, have_escape_prefix) {
Some(mut nested_sequence) => {
if nested_sequence == invalid {
return Some(Key::from_raw(key::Escape));
}
nested_sequence.modifiers.alt = true;
nested_sequence
}
None => invalid,
_ => invalid,
},
);
}

View File

@@ -24,7 +24,7 @@
pub(crate) const Insert: char = '\u{F50c}';
pub(crate) const Tab: char = '\u{F50d}';
pub(crate) const Space: char = '\u{F50e}';
pub const Invalid: char = '\u{F50f}';
pub(crate) const Invalid: char = '\u{F50f}';
pub(crate) fn function_key(n: u32) -> char {
assert!((1..=12).contains(&n));
char::from_u32(u32::from(Invalid) + n).unwrap()