feat: character-level chat selection that persists after mouse release - #236
Draft
wowi42 wants to merge 2 commits into
Draft
feat: character-level chat selection that persists after mouse release#236wowi42 wants to merge 2 commits into
wowi42 wants to merge 2 commits into
Conversation
Two related fixes (item from gi-dellav#186): - Selection endpoints are now (visual_line, display_col) points instead of whole-row indices. Mouse drag honors the column, the highlight renders as a partial-line reversed segment (CJK-aware slicing via new ui::utils display-column helpers), and selected_text()/y copy extract exactly the highlighted range: first/last lines sliced, middle lines whole. - Bug: mouse release used to copy and immediately clear the selection, so the highlight vanished the moment the button was let go. The selection now stays visible after release; y copies it, Esc clears it, and the next click starts a new one.
While mouse capture is enabled the terminal emulator has no native selection, so Cmd+C (macOS) / Ctrl+Shift+C (Linux) has nothing to copy — the app must write the pasteboard itself. Mouse release now copies the selection via copy_to_clipboard (pbcopy/wl-copy/xclip/clip.exe) with a "copied selection" confirmation, and the highlight still persists for y/Esc.
Contributor
Author
|
Follow-up (0fa1d4d): selection is now also copied to the system clipboard on mouse release — with mouse capture enabled the terminal emulator has no native selection, so Cmd+C/Ctrl+Shift+C has nothing to copy and the app must write the pasteboard itself. The highlight still persists for y/Esc. Verified on macOS: pbpaste contains the selected text after release. |
wowi42
marked this pull request as draft
July 28, 2026 05:27
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Implements item 4 of the "Input and pickers" section of #186 ("Support character-level selection: mouse drag and
ycopy currently select whole visual rows only") and fixes a UX bug where the selection disappeared the moment the mouse button was released.Changes
Character-level selection
(visual_line, display_col)points instead of whole-rowLineEntryindices;MouseDraghonors the column it previously ignored.byte_index_at_display_col/display_col_slicehelpers inui::utils.selected_text()(and thereforeycopy) extracts exactly the highlighted range, normalizing reversed/upward drags.Selection persists after mouse release, and is copied on release
MouseUpcopied to clipboard and immediately cleared the selection, so the highlight vanished on release. Now the drag ends (selection_draggingtracks the button state separately fromselection_active) but the highlight stays:ycopies again,Escclears, the next click starts a new selection.copy_to_clipboard(pbcopy/wl-copy/xclip/clip.exe): while mouse capture is enabled the terminal emulator has no native selection, so Cmd+C (macOS) / Ctrl+Shift+C (Linux) has nothing to grab — the app must write the pasteboard itself.Verification
cargo test(720 passed),cargo test --no-default-features(605),cargo clippy --all-featuresand--no-default-featureswith-D warnings— all clean.selected_text(first/last line slicing, reversed drag, empty point selection).ycopies it.Refs #186