From 45a4318bbbcb2c91d95faee6f31e5846ae3f9ec0 Mon Sep 17 00:00:00 2001 From: leeeanh <44962286+leeeanh@users.noreply.github.com> Date: Sun, 17 May 2026 19:05:30 +0700 Subject: feat: add selection autoscroll and fix stale selection on transitions (#129) When dragging to select text near pane edges, a 30ms recurring tick now continues scrolling and extending the selection while the mouse is idle. The autoscroll stops on MouseUp, key input, navigate action, cursor leaving the hot zone, scrollback boundary, missing metrics, or pane rect change. Also fixes pre-existing bugs where workspace/tab/pane transitions failed to clear selection state, which could cause stale selections to persist across views. Selection clearing on pane death is scoped to only the dying pane. Also fixes anchor_screen_pos returning pane-relative coordinates instead of screen coordinates, which caused false drag detection and spurious edge autoscroll on same-cell events when the pane has a non-zero origin. refs #128 Co-authored-by: leeanh --- src/app/input/mod.rs | 9 +++++++++ 1 file changed, 9 insertions(+) (limited to 'src/app/input/mod.rs') diff --git a/src/app/input/mod.rs b/src/app/input/mod.rs index 7823de31..93152e55 100644 --- a/src/app/input/mod.rs +++ b/src/app/input/mod.rs @@ -177,6 +177,15 @@ impl App { tracing::warn!("failed to queue clipboard write event"); } } + + // Sync autoscroll deadline with state (mouse handler may have + // set or cleared selection_autoscroll during handle_mouse). + if self.state.selection_autoscroll.is_none() { + self.selection_autoscroll_deadline = None; + } else if self.selection_autoscroll_deadline.is_none() { + self.selection_autoscroll_deadline = + Some(std::time::Instant::now() + super::SELECTION_AUTOSCROLL_INTERVAL); + } } } -- cgit v1.2.3