Repository navigation
Only start a terminal highlight once a drag leaves the pressed cell - #126
Conversation
03fc03b to
c72b10d
Compare
|
It now no longer highlights a cell at the slightest move, but when the mouse moves by a cell, only 2 cells get highlighted and further drags does not highlight anyting more. So it seems like the underlying issue wasn't solved |
|
Thanks for testing @zhengqunkoo, that stall is a good clue. My best guess: every drag tick copied the selection to the clipboard, which starts a clipboard process synchronously, so the UI froze as soon as the drag left the first cell. b1197e6 copies once on mouse release instead. The highlight should keep growing during the drag, and the clipboard fills when you let go. Programs that ask for button-motion events (1002/1003) now get the drag instead of it being swallowed. I can't reproduce the GUI side here, so could you give it another try? |
b1197e6 to
b538256
Compare
The mouse SDK calls SetSelectionEnd for every held-button event, even while the pointer stays in the pressed cell, so a click to focus the window highlighted one cell and copied it over the clipboard. The SDK also auto-scrolls after each of those events near the top or bottom edge, so a click in the top rows of a scrolled-back terminal moved the view off the pressed cell and copied that way. The terminal now neither highlights, scrolls nor copies until a drag reaches another cell. Highlight-to-copy on real drags, double-click and triple-click is unchanged. The clipboard docs now describe it, and that a program tracking the mouse owns clicks and drags. Fixes unstablebuild#125 Signed-off-by: Matt Van Horn <[email protected]>
Copying on every drag tick runs the system clipboard command and waits for it on the event loop, the suspected cause of a drag highlight that stopped growing after two cells on Wayland. The highlight now follows the drag and is copied once, when the gesture ends. The gesture ends at the next mouse action rather than only at its release, so a later right- or middle-click release does not copy the old highlight again, and nothing is copied when Esc cleared the highlight during the drag. Signed-off-by: Matt Van Horn <[email protected]>
The mouse SDK scrolls down while a drag is in the last rows of the pane, measured against the delegate's Height. The terminal reported the whole buffer, scrollback included, so once the history outgrew the screen the bottom zone fell below the pane: dragging down neither scrolled nor extended the highlight past the last visible row. Report the rows the window shows instead. Co-Authored-By: Rune Agent (claude/claude-opus-5-5) <[email protected]> Signed-off-by: ernestrc <[email protected]>
The mouse SDK auto-scrolled up whenever a drag was in the top rows, regardless of direction, so pressing near the top and dragging down scrolled the view up and grew the selection the wrong way. rune-go-sdk v0.7.1 only scrolls toward the edge the selection grows to, tracking the pressed row as the view moves. That tracking relies on ScrollUp and ScrollDown reporting whether the view moved, which the terminal never did. Co-Authored-By: Rune Agent (claude/claude-opus-5-5) <[email protected]> Signed-off-by: ernestrc <[email protected]>
b538256 to
779ad12
Compare
|
Codecov Report❌ Patch coverage is
📢 Thoughts on this report? Let us know! |
|
@ernestrc thanks! Clicking a terminal to focus it won't clobber the clipboard with a single character anymore. |
Thank you for pitching in! |
Fixes #175. The SDK reports held-button moves, including pointer jitter inside the pressed cell, through `SetSelectionEnd`. The Vim mouse delegate selected the cell and switched to visual mode in `SetSelectionStart`, before any drag could be told apart from a click, so focusing the window with the mouse left a one-cell highlight that survived scrolling and forced an Esc to get back to normal mode — the same shape #126 fixed on the terminal side. Signed-off-by: Santhi Prakash <[email protected]>
Clicking a terminal to focus it could replace the clipboard with a single character. The mouse SDK calls
SetSelectionEndfor every held-button event, including pointer jitter inside the pressed cell, so a click with slight movement highlighted one cell and copied it. The terminal driver now waits until a drag reaches a different cell before it highlights and copies, which matches gnome-terminal.The second part is the case @zhengqunkoo described with vim: when the running program tracks the mouse, the press goes to the program and no selection is anchored in the terminal, but the drag events that follow still painted a terminal highlight from a stale anchor and copied it. That highlight then stayed on its cell while vim scrolled. In that mode, clicks and drags now go to the program only.
Highlight-to-copy on real drags, double-click and triple-click works as before. The clipboard docs now describe both behaviors, since the issue noted they were undocumented.
Verification: new table tests in
internal/term/vte/mouse_test.gocover a click, same-cell jitter, drags in each direction, dragging away and back, a mouse-tracking program, and word and line selection. The jitter and mouse-tracking cases fail on main and pass with this change.go test ./internal/term/...,go vetandgolangci-lintpass.Fixes #125
AI was used for assistance.
🤖 Generated with Claude Code
https://claude.ai/code/session_01A4fR1AynHqTUCqgzCsrRg3