fish_key_reader: ignore sentinel key

Also, move the undo grouping for paste to the right place.
This commit is contained in:
Johannes Altmanninger 2024-04-02 16:24:37 +02:00
parent 8bf8b10f68
commit e8e91c97a6
4 changed files with 7 additions and 4 deletions

View file

@ -20,7 +20,7 @@ use fish::{
eprintf, fprintf,
input::input_terminfo_get_name,
input_common::{CharEvent, InputEventQueue, InputEventQueuer},
key::Key,
key::{self, Key},
panic::panic_handler,
print_help::print_help,
printf,
@ -117,6 +117,9 @@ fn process_input(continuous_mode: bool) -> i32 {
continue;
};
let c = kevt.key.codepoint;
if c == key::Invalid {
continue;
}
bind_chars.push((kevt.key, kevt.seq));
output_bind_command(&mut bind_chars);
if output_matching_key_name(&mut recent_chars1, c) {

View file

@ -456,11 +456,13 @@ impl InputEventQueuer for Inputter {
fn paste_start_buffering(&mut self) {
self.paste_buffer = Some(vec![]);
self.push_front(CharEvent::from_readline(ReadlineCmd::BeginUndoGroup));
}
fn paste_is_buffering(&self) -> bool {
self.paste_buffer.is_some()
}
fn paste_commit(&mut self) {
self.push_front(CharEvent::from_readline(ReadlineCmd::EndUndoGroup));
let buffer = self.paste_buffer.take().unwrap();
self.push_front(CharEvent::Command(sprintf!(
"__fish_paste %s",

View file

@ -869,11 +869,9 @@ pub trait InputEventQueuer {
} // rxvt style
200 => {
self.paste_start_buffering();
self.push_front(CharEvent::from_readline(ReadlineCmd::BeginUndoGroup));
return Some(Key::from_raw(key::Invalid));
}
201 => {
self.push_front(CharEvent::from_readline(ReadlineCmd::EndUndoGroup));
self.paste_commit();
return Some(Key::from_raw(key::Invalid));
}

View file

@ -22,7 +22,7 @@ pub(crate) const End: char = '\u{F50b}';
pub(crate) const Insert: char = '\u{F50c}';
pub(crate) const Tab: char = '\u{F50d}';
pub(crate) const Space: char = '\u{F50e}';
pub(crate) const Invalid: char = '\u{F50f}';
pub 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()