From b33e5f973fc89381aa4ac72b3a31fa087ec66e23 Mon Sep 17 00:00:00 2001 From: Ogulcan Celik Date: Sat, 25 Jul 2026 02:40:27 +0300 Subject: fix: copy retained mouse selections with keyboard shortcuts refs #1782 --- src/app/input/mod.rs | 31 ++++++++++++------------------- 1 file changed, 12 insertions(+), 19 deletions(-) (limited to 'src/app/input/mod.rs') diff --git a/src/app/input/mod.rs b/src/app/input/mod.rs index f304cde6..a2e6597b 100644 --- a/src/app/input/mod.rs +++ b/src/app/input/mod.rs @@ -36,6 +36,7 @@ fn modified_url_click_modifier_matches_terminal_mouse_reporting() { assert_eq!(modified_url_click_modifier(), KeyModifiers::CONTROL); } +mod clipboard; mod copy_mode; mod modal; mod mouse; @@ -401,15 +402,7 @@ impl App { self.save_agent_panel_sort(self.state.agent_panel_sort); } - if let Some(content) = self.state.request_clipboard_write.take() { - if self - .event_tx - .try_send(crate::events::AppEvent::ClipboardWrite { content }) - .is_err() - { - tracing::warn!("failed to queue clipboard write event"); - } - } + self.dispatch_pending_clipboard_write(); // Sync autoscroll deadline with state (mouse handler may have // set or cleared selection_autoscroll during handle_mouse). @@ -569,14 +562,12 @@ impl App { }; // Require the second click to land near the first click in the same pane - // and within the double-click window so adjacent interactions do not copy. + // and within the double-click window so adjacent interactions do not select a word. if !self.take_pane_double_click(click) { return false; } - // Preserve a short highlight after copying so the user gets visible - // confirmation without leaving a persistent selection behind. - self.copy_double_clicked_word(click) + self.select_double_clicked_word(click) } fn pane_click_candidate(&mut self, mouse: MouseEvent) -> Option { @@ -620,18 +611,20 @@ impl App { true } - fn copy_double_clicked_word(&mut self, click: PaneClickState) -> bool { - let copied = self.state.copy_word_at_pane_cell( + fn select_double_clicked_word(&mut self, click: PaneClickState) -> bool { + let selected = self.state.select_word_at_pane_cell( &self.terminal_runtimes, click.pane_id, click.viewport_row, click.col, ); - if copied { - self.selection_highlight_clear_deadline = - Some(std::time::Instant::now() + super::PANE_COPY_HIGHLIGHT_DURATION); + if selected { + self.selection_highlight_clear_deadline = self + .state + .copy_on_select + .then(|| std::time::Instant::now() + super::PANE_COPY_HIGHLIGHT_DURATION); } - copied + selected } } -- cgit v1.2.3