diff --git a/src/builtins/fish_key_reader.rs b/src/builtins/fish_key_reader.rs index 94f017352..98c03df7e 100644 --- a/src/builtins/fish_key_reader.rs +++ b/src/builtins/fish_key_reader.rs @@ -101,7 +101,7 @@ fn process_input( } CharEvent::Key(kevt) => kevt, CharEvent::Readline(_) | CharEvent::Command(_) | CharEvent::Implicit(_) => continue, - CharEvent::QueryResult(Timeout) => panic!("should not be querying"), + CharEvent::QueryResult(Timeout | Interrupted) => panic!("should not be querying"), CharEvent::QueryResult(Response(_)) => continue, }; if verbose { diff --git a/src/input_common.rs b/src/input_common.rs index 1d59e2091..4c2d839f2 100644 --- a/src/input_common.rs +++ b/src/input_common.rs @@ -318,8 +318,6 @@ pub enum ImplicitEvent { /// An event was handled internally, or an interrupt was received. Check to see if the reader /// loop should exit. CheckExit, - /// A blocking terminal query was interrupterd with ctrl-c. - QueryInterrupted, /// Our terminal window gained focus. FocusIn, /// Our terminal window lost focus. @@ -338,6 +336,8 @@ pub enum QueryResponse { pub enum QueryResultEvent { Response(QueryResponse), Timeout, + /// Canceled with ctrl-c. + Interrupted, } #[derive(Debug, Clone)] @@ -726,8 +726,7 @@ fn try_pop(&mut self) -> Option { if self.is_blocked_querying() { use ImplicitEvent::*; match self.get_input_data().queue.front()? { - CharEvent::QueryResult(_) - | CharEvent::Implicit(CheckExit | Eof | QueryInterrupted) => {} + CharEvent::QueryResult(_) | CharEvent::Implicit(CheckExit | Eof) => {} CharEvent::Key(_) | CharEvent::Readline(_) | CharEvent::Command(_) @@ -869,7 +868,7 @@ fn readch(&mut self) -> CharEvent { let ok = stop_query(self.blocking_query()); assert!(ok); self.get_input_data_mut().queue.clear(); - self.push_front(CharEvent::Implicit(ImplicitEvent::QueryInterrupted)); + self.push_front(CharEvent::QueryResult(QueryResultEvent::Interrupted)); } continue; } @@ -1547,7 +1546,7 @@ fn enqueue_interrupt_key(&mut self) { "Received interrupt, giving up on waiting for terminal response" ); self.get_input_data_mut().queue.clear(); - self.push_front(CharEvent::Implicit(ImplicitEvent::QueryInterrupted)); + self.push_front(CharEvent::QueryResult(QueryResultEvent::Interrupted)); } else { self.push_front(interrupt_evt); } diff --git a/src/reader/reader.rs b/src/reader/reader.rs index 6d2ea40b1..5f9b7aa97 100644 --- a/src/reader/reader.rs +++ b/src/reader/reader.rs @@ -274,15 +274,15 @@ pub fn terminal_init(vars: &dyn Environment, inputfd: RawFd) -> InputEventQueue while !check_exit_loop_maybe_warning(None) { use CharEvent::{Command, Implicit, Key, Readline}; - use ImplicitEvent::{CheckExit, Eof, QueryInterrupted}; + use ImplicitEvent::{CheckExit, Eof}; use QueryResultEvent::*; match input_queue.readch() { Implicit(Eof) => reader_sighup(), Implicit(CheckExit) => {} - Implicit(QueryInterrupted) => break, CharEvent::QueryResult(Response(QueryResponse::PrimaryDeviceAttribute)) => { break; } + CharEvent::QueryResult(Response(_)) => (), CharEvent::QueryResult(Timeout) => { let program = get_program_name(); FLOG!( @@ -304,7 +304,7 @@ pub fn terminal_init(vars: &dyn Environment, inputfd: RawFd) -> InputEventQueue .replace(Duration::from_millis(30)); break; } - CharEvent::QueryResult(Response(_)) => (), + CharEvent::QueryResult(Interrupted) => break, Key(_) | Readline(_) | Command(_) | Implicit(_) => panic!(), }; } @@ -2614,7 +2614,6 @@ fn handle_char_event(&mut self, injected_event: Option) -> ControlFlo CharEvent::Implicit(implicit_event) => match implicit_event { ImplicitEvent::Eof => reader_sighup(), ImplicitEvent::CheckExit => (), - ImplicitEvent::QueryInterrupted => (), ImplicitEvent::FocusIn => { event::fire_generic(self.parser, L!("fish_focus_in").to_owned(), vec![]); self.save_screen_state(); @@ -2647,7 +2646,7 @@ fn handle_char_event(&mut self, injected_event: Option) -> ControlFlo } ( Some(TerminalQuery::CursorPosition(cursor_pos_query)), - Response(PrimaryDeviceAttribute) | Timeout, + Response(PrimaryDeviceAttribute) | Timeout | Interrupted, ) => { let cursor_pos_query = cursor_pos_query.clone(); drop(maybe_query);