From 26a1b93098407c51b57508da7ab8050c2a1ee516 Mon Sep 17 00:00:00 2001 From: Hamza Hamud <53880692+hhamud@users.noreply.github.com> Date: Mon, 20 Mar 2023 18:08:29 +0000 Subject: [PATCH] fix: paste into terminal after switching modes (#793) * fix: paste into terminal after switching modes * fix: remove collect and fix format --- src/command/client/search/interactive.rs | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/src/command/client/search/interactive.rs b/src/command/client/search/interactive.rs index c1d1c175..ed57a3f7 100644 --- a/src/command/client/search/interactive.rs +++ b/src/command/client/search/interactive.rs @@ -114,6 +114,7 @@ impl State { match input { Event::Key(k) => self.handle_key_input(settings, k, len), Event::Mouse(m) => self.handle_mouse_input(*m, len), + Event::Paste(d) => self.handle_paste_input(d), _ => None, } } @@ -133,6 +134,13 @@ impl State { None } + fn handle_paste_input(&mut self, input: &str) -> Option { + for i in input.chars() { + self.search.input.insert(i); + } + None + } + #[allow(clippy::too_many_lines)] fn handle_key_input( &mut self, @@ -451,7 +459,8 @@ impl Stdout { execute!( stdout, terminal::EnterAlternateScreen, - event::EnableMouseCapture + event::EnableMouseCapture, + event::EnableBracketedPaste )?; Ok(Self { stdout }) } @@ -462,7 +471,8 @@ impl Drop for Stdout { execute!( self.stdout, terminal::LeaveAlternateScreen, - event::DisableMouseCapture + event::DisableMouseCapture, + event::DisableBracketedPaste ) .unwrap(); terminal::disable_raw_mode().unwrap();