From 953ff58e9febfc428ebef4db98e3b496ba487d69 Mon Sep 17 00:00:00 2001 From: Ogulcan Celik Date: Thu, 9 Apr 2026 17:51:28 +0300 Subject: fix: autoscroll and clear mouse text selections --- src/app/actions.rs | 42 +++++++++++++++++++++++++++--------------- 1 file changed, 27 insertions(+), 15 deletions(-) (limited to 'src/app/actions.rs') diff --git a/src/app/actions.rs b/src/app/actions.rs index 3622787e..6989a909 100644 --- a/src/app/actions.rs +++ b/src/app/actions.rs @@ -357,33 +357,45 @@ impl AppState { } pub fn copy_selection(&mut self) { - let sel = match self.selection.as_mut() { - Some(s) => { - if !s.finish() { + let text = { + let sel = match self.selection.as_mut() { + Some(s) => { + if !s.finish() { + self.selection = None; + return; + } + s + } + None => return, + }; + + let ws = match self.active.and_then(|i| self.workspaces.get(i)) { + Some(ws) => ws, + None => { self.selection = None; return; } - s - } - None => return, - }; + }; - let ws = match self.active.and_then(|i| self.workspaces.get(i)) { - Some(ws) => ws, - None => return, - }; + let rt = match ws.runtime(sel.pane_id) { + Some(r) => r, + None => { + self.selection = None; + return; + } + }; - let rt = match ws.runtime(sel.pane_id) { - Some(r) => r, - None => return, + rt.extract_selection(sel) }; - if let Some(text) = rt.extract_selection(sel) { + if let Some(text) = text { if !text.is_empty() { crate::selection::write_osc52(&text); info!(len = text.len(), "copied selection to clipboard"); } } + + self.selection = None; } } -- cgit v1.2.3