fix(tmux): return to the prompt on click release, not on press

MouseDown cancelled copy-mode before a drag could start, so selecting text
after scrolling up jumped back to the bottom. MouseUp1Pane (sent only when
no drag happened) now cancels; MouseDown clears the selection as before.
This commit is contained in:
bchanot
2026-10-06 15:17:21 +02:00
parent 8ab681627c
commit 51aed0e24d
+6 -4
View File
@@ -151,12 +151,14 @@ if-shell 'command -v pbcopy >/dev/null' \
bind-key -Tcopy-mode-vi Escape send -X cancel # cancel v mode
bind-key -Tcopy-mode-vi ^v send -X rectangle-toggle # cancel v mode
bind-key -T copy-mode-vi MouseDown1Pane select-pane -t = \; send-keys -X cancel
bind-key -T copy-mode-vi MouseDown1Pane select-pane -t = \; send-keys -X clear-selection
bind-key -T copy-mode-vi MouseUp1Pane select-pane -t = \; send-keys -X cancel
bind -n MouseDrag1Pane if -Ft= '#{mouse_any_flag}' 'if -Ft= \"#{pane_in_mode}\" \"copy-mode -eM\" \"send-keys -M\"' 'copy-mode -eM'
# (note) {{{
# The `bind-key -T copy-m...` makes a single click leave copy-mode: back to
# the prompt, selection dropped. A drag still selects (MouseDrag1Pane below
# re-enters copy-mode) and a click on another pane still switches to it.
# A plain click (MouseDown then MouseUp, no drag) leaves copy-mode: back to
# the prompt, selection dropped. A drag sends MouseDrag/MouseDragEnd instead
# of MouseUp, so it keeps the scroll position and selects as usual. A click
# on another pane still switches to it.
# The `bind -n MouseDrag1Pane if -Ft= ...` changes the default binding of
# MouseDrag1Pane, the only difference is that we use `copy-mode -eM` instead
# of `copy-mode -M`, so that WheelDownPane can trigger copy-mode to exit when