diff options
| author | Zack Drach <zackdrach@gmail.com> | 2026-05-26 03:40:29 -0700 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2026-05-26 13:40:29 +0300 |
| commit | 6c4a947244b7be05496f9d3bd5ad2d00a69cca03 (patch) | |
| tree | 421b4a009e2a201c9be65806fd0e13fe9899c73a /src/app/input/mouse.rs | |
| parent | 33e71ed2f50e5ca8950029f89f41e0ec135b87c0 (diff) | |
Add tmux-style double-click word copy (#296)
* feat: add tmux-style double-click copy
Double-clicking terminal output now selects and copies the token under the cursor, similar to tmux. The copied token briefly stays highlighted as feedback, and token detection handles common shell output like paths, URLs, variables, CJK text, and surrounding punctuation.
Mouse events are still forwarded unchanged when the child terminal has mouse reporting enabled.
refs #142
* fix: tighten double-click copy
refs #142
---------
Co-authored-by: Can Celik <ogulcancelik@gmail.com>
Diffstat (limited to 'src/app/input/mouse.rs')
| -rw-r--r-- | src/app/input/mouse.rs | 18 |
1 files changed, 7 insertions, 11 deletions
diff --git a/src/app/input/mouse.rs b/src/app/input/mouse.rs index 87c14756..8adfa55b 100644 --- a/src/app/input/mouse.rs +++ b/src/app/input/mouse.rs @@ -728,16 +728,19 @@ impl AppState { } MouseEventKind::Up(MouseButton::Left) => { - if self.selection.is_some() { + // Mouse-up either finishes a drag selection or releases after a + // double-click copy; the latter is already copied. + if let Some(selection) = self.selection.as_ref() { + let was_click = selection.was_just_click(); + let was_already_copied = selection.is_done(); + self.workspace_press = None; self.tab_press = None; self.drag = None; self.selection_autoscroll = None; - let was_click = self.selection.as_ref().is_some_and(|s| s.was_just_click()); if was_click { self.selection = None; - self.selection_autoscroll = None; - } else { + } else if !was_already_copied { self.copy_selection(terminal_runtimes); } return None; @@ -795,13 +798,6 @@ impl AppState { return None; } } - let was_click = self.selection.as_ref().is_some_and(|s| s.was_just_click()); - if was_click { - self.selection = None; - self.selection_autoscroll = None; - } else { - self.copy_selection(terminal_runtimes); - } } } } |
