diff --git a/src/bin/fish_key_reader.rs b/src/bin/fish_key_reader.rs index b401621b1..7412b27fc 100644 --- a/src/bin/fish_key_reader.rs +++ b/src/bin/fish_key_reader.rs @@ -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() { diff --git a/src/input_common.rs b/src/input_common.rs index 704bfbb72..eaa253dfc 100644 --- a/src/input_common.rs +++ b/src/input_common.rs @@ -691,6 +691,7 @@ fn try_readch(&mut self, blocking: bool) -> Option { 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; @@ -767,10 +768,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, }, ); } diff --git a/src/key.rs b/src/key.rs index 7b8346ff5..59a8ce56e 100644 --- a/src/key.rs +++ b/src/key.rs @@ -23,7 +23,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()