Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

check selection's visible width when copying on mouse click #2711

Merged

Conversation

the-mikedavis
Copy link
Member

Mouse-click-up copies the selection produced by dragging. The event
is ignored if the selection has a width of 1 though so you don't
copy when clicking rather than dragging. The current check copies
text when it has a visible width of 1 but is actually multiple
characters in the rope like a CRLF line-ending. With this change
we check the unicode width of the character(s) in the selection
rather than the range length, so clicking on a CRLF line-ending
does not copy.

Closes #2699

Mouse-click-up copies the selection produced by dragging. The event
is ignored if the selection has a width of 1 though so you don't
copy when clicking rather than dragging. The current check copies
text when it has a visible width of 1 but is actually multiple
characters in the rope like a CRLF line-ending. With this change
we check the unicode width of the character(s) in the selection
rather than the range length, so clicking on a CRLF line-ending
does not copy.
@CptPotato
Copy link
Contributor

A small additional thing: Yanking doesn't require the selection to have changed; so you can select something in visual/normal mode, click outside the document (for example on the status line) and the selection is yanked.

This is a bit of an edge-case, though, and I'm not sure if it's worth the effort to change the implementation to fix that.

helix-term/src/ui/editor.rs Outdated Show resolved Hide resolved
@archseer archseer merged commit d948ace into helix-editor:master Jun 24, 2022
@the-mikedavis the-mikedavis deleted the md-mouse-click-check-display-width branch June 24, 2022 13:59
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Clicking past the end of a line triggers yank
3 participants