Mouse selection should begin and end at nearest cell boundary #7119

Closed
opened 2026-01-31 00:55:38 +00:00 by claunia · 7 comments
Owner

Originally created by @egmontkob on GitHub (Mar 24, 2020).

Description of the new feature/enhancement

For the intuitive highlighting behavior, and consistency with most other applications; when selecting text with the mouse, the two endpoints should be rounded to the nearest vertical boundary between adjacent characters, and highlight/select whatever is between these two points; rather than necessarily including the character the mouse was clicked on / released at.

Note that this is for single click only. For double click, it's the characters under the click location and the release endpoint that should be expanded.

For more details, rationale etc. see for example https://github.com/kovidgoyal/kitty/issues/945.

Originally created by @egmontkob on GitHub (Mar 24, 2020). <!-- 🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨 I ACKNOWLEDGE THE FOLLOWING BEFORE PROCEEDING: 1. If I delete this entire template and go my own path, the core team may close my issue without further explanation or engagement. 2. If I list multiple bugs/concerns in this one issue, the core team may close my issue without further explanation or engagement. 3. If I write an issue that has many duplicates, the core team may close my issue without further explanation or engagement (and without necessarily spending time to find the exact duplicate ID number). 4. If I leave the title incomplete when filing the issue, the core team may close my issue without further explanation or engagement. 5. If I file something completely blank in the body, the core team may close my issue without further explanation or engagement. All good? Then proceed! --> # Description of the new feature/enhancement <!-- A clear and concise description of what the problem is that the new feature would solve. Describe why and how a user would use this new functionality (if applicable). --> For the intuitive highlighting behavior, and consistency with most other applications; when selecting text with the mouse, the two endpoints should be rounded to the _nearest vertical boundary_ between adjacent characters, and highlight/select whatever is between these two points; rather than necessarily including the character the mouse was clicked on / released at. Note that this is for single click only. For double click, it's the characters under the click location and the release endpoint that should be expanded. For more details, rationale etc. see for example https://github.com/kovidgoyal/kitty/issues/945.
Author
Owner

@DHowett-MSFT commented on GitHub (Mar 25, 2020):

I set about doing this as part of the outstanding selection refactor, and immediately ran into our selection endpoints not being exclusive on the right. @carlos-zamora, do you remember why this differed from a11y?

@DHowett-MSFT commented on GitHub (Mar 25, 2020): I set about doing this as part of the outstanding selection refactor, and immediately ran into our selection endpoints not being exclusive on the right. @carlos-zamora, do you remember why this differed from a11y?
Author
Owner

@carlos-zamora commented on GitHub (May 12, 2020):

I set about doing this as part of the outstanding selection refactor, and immediately ran into our selection endpoints not being exclusive on the right. @carlos-zamora, do you remember why this differed from a11y?

I worked on selection before I worked on accessibility, so that's why haha. This would be a fun refactor I can do. And further combine the accessibility/selection code since they have so much in common.

@carlos-zamora commented on GitHub (May 12, 2020): > I set about doing this as part of the outstanding selection refactor, and immediately ran into our selection endpoints not being exclusive on the right. @carlos-zamora, do you remember why this differed from a11y? I worked on selection before I worked on accessibility, so that's why haha. This would be a fun refactor I can do. And further combine the accessibility/selection code since they have so much in common.
Author
Owner

@vefatica commented on GitHub (Feb 12, 2021):

What's the status of this issue? I, also, would like to be able to select a line and get a newline and NOT get the first character of the next line.

@vefatica commented on GitHub (Feb 12, 2021): What's the status of this issue? I, also, would like to be able to select a line and get a newline and NOT get the first character of the next line.
Author
Owner

@DHowett commented on GitHub (Feb 12, 2021):

The status of this issue is: Open.

@DHowett commented on GitHub (Feb 12, 2021): The status of this issue is: Open.
Author
Owner

@DHowett commented on GitHub (Feb 12, 2021):

We have a different issue tracking "the space at the end of the line should be treated as the newline."

@DHowett commented on GitHub (Feb 12, 2021): We have a different issue tracking "the space at the end of the line should be treated as the newline."
Author
Owner

@vefatica commented on GitHub (Feb 12, 2021):

We have a different issue tracking "the space at the end of the line should be treated as the newline."

I'm not often successful when using this forum's search mechanism. How would I search for the above-mentioned issue?

@vefatica commented on GitHub (Feb 12, 2021): > We have a different issue tracking "the space at the end of the line should be treated as the newline." I'm not often successful when using this forum's search mechanism. How would I search for the above-mentioned issue?
Author
Owner

@zadjii-msft commented on GitHub (Sep 9, 2022):

Notes from https://github.com/microsoft/terminal/issues/11027

2. Another option would be to provide a configuration option to specify the minimum mouse movement (in pixels) before starting automatic copy selection. The default should be larger than is currently implemented - unless there is some issue with compatibility of UI experience. Or maybe it doesn't need to be configurable, just use a better minimum movement.
Since it is unlikely that anyone wants to select a single character (or even two?), I think a reasonable default might be 1 character width. Actually anything up to 1 character height (to select a full line, moving down) would probably work.

I think this is kinda like #5099? (#5082 + #5096) made this a lot better, but it's still not perfect. I believe the threshold right now is 25% of the min(width, height) of a glyph.

Thanks for the pointers. I suspect that a fix to #5099 would fix my issue as well (looks like my proposal 1). But perhaps my proposal 2 is even easier to fix, as your comment (and #5096) implies:

the threshold right now is 25% of the min(width, height) of a glyph

I would argue that changing 25% to 100% would work as well for real selections, since that allows for moving from the centre of one glyph to the centre of the next. It could be even more, since one rarely needs to select a single character.

On the other hand any increase in the threshold would reduce the number of spurious selections, so a conservative change might be to increase the threshold to 75%.

@zadjii-msft commented on GitHub (Sep 9, 2022): Notes from https://github.com/microsoft/terminal/issues/11027 > 2\. Another option would be to provide a configuration option to specify the minimum mouse movement (in pixels) before starting automatic copy selection. The default should be larger than is currently implemented - unless there is some issue with compatibility of UI experience. Or maybe it doesn't need to be configurable, just use a better minimum movement. > Since it is unlikely that anyone wants to select a single character (or even two?), I think a reasonable default might be 1 character width. Actually anything up to 1 character height (to select a full line, moving down) would probably work. > I think this is kinda like #5099? (#5082 + #5096) made this a lot better, but it's still not perfect. I believe the threshold right now is 25% of the `min(width, height)` of a glyph. > Thanks for the pointers. I suspect that a fix to #5099 would fix my issue as well (looks like my proposal 1). But perhaps my proposal 2 is even easier to fix, as your comment (and #5096) implies: > > > the threshold right now is 25% of the `min(width, height)` of a glyph > > I would argue that changing 25% to 100% would work as well for real selections, since that allows for moving from the centre of one glyph to the centre of the next. It could be even more, since one rarely needs to select a single character. > > On the other hand any increase in the threshold would reduce the number of spurious selections, so a conservative change might be to increase the threshold to 75%.
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/terminal#7119