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

Make selection an exclusive range #18106

Open
wants to merge 34 commits into
base: main
Choose a base branch
from
Open
Changes from 1 commit
Commits
Show all changes
34 commits
Select commit Hold shift + click to select a range
aa95790
[AtlasEngine] Render selection as exclusive range
carlos-zamora Oct 15, 2024
4697f49
Fix any side-effects of making GetText exclusive
carlos-zamora Oct 15, 2024
4364643
Update selection markers appropriately
carlos-zamora Oct 15, 2024
014f338
[Mark Mode] Move by character (includes wide-glyph handling)
carlos-zamora Oct 16, 2024
ba673a4
[Mark Mode] Move by viewport
carlos-zamora Oct 16, 2024
cd2da0e
[Mark Mode] Move by buffer
carlos-zamora Oct 16, 2024
ff45eb9
[Mark Mode] Move by word
carlos-zamora Oct 17, 2024
659cd02
[Mark Mode] Handle move up/down onto middle of emoji
carlos-zamora Oct 17, 2024
e7ca807
Bugfix: renderer highlights lines when at x-boundary
carlos-zamora Oct 18, 2024
7ff4838
Bugfix: move to next word would move past mutable bottom
carlos-zamora Oct 18, 2024
928e9a9
Fix some more rendering issues
carlos-zamora Oct 21, 2024
9d361d2
Fix more rendering issues w/ Leonard
carlos-zamora Oct 21, 2024
845e43d
Fix highlighting in AtlasEngine
lhecker Oct 22, 2024
8b996a9
fix session restore
carlos-zamora Oct 22, 2024
df89ad0
Ensure mouse selection scenarios work right
carlos-zamora Oct 23, 2024
9e9db42
Fix UIA
carlos-zamora Oct 23, 2024
eea8399
Fix hyperlinks
carlos-zamora Oct 23, 2024
7bfd647
fix tests
carlos-zamora Oct 24, 2024
52f3bc0
fix other tests
carlos-zamora Nov 5, 2024
408d149
spell
carlos-zamora Nov 5, 2024
57b82cb
[UIA] allow end exclusive
carlos-zamora Nov 6, 2024
e98033e
audit
carlos-zamora Nov 6, 2024
e621c1c
fix some more tests
carlos-zamora Nov 7, 2024
83d2bff
apply feedback
carlos-zamora Nov 8, 2024
6aed5f9
Fix shift+tab to select hyperlink
carlos-zamora Nov 15, 2024
7a8d448
Fix ConHost
carlos-zamora Nov 15, 2024
6b99816
Fix 'off by 1' hyperlink detection
carlos-zamora Nov 15, 2024
d179e9c
bugfix: don't select trailing whitespace with mouse word selection
carlos-zamora Nov 26, 2024
d2ed09e
bugfix: click+drag on cell should select the cell we're on
carlos-zamora Nov 26, 2024
37ad74f
bugfix: double-click + drag would prematurely expand
carlos-zamora Dec 3, 2024
dbfdf81
fix tests; fix conhost block selection
carlos-zamora Dec 3, 2024
bee9371
fix terminal core selection tests
carlos-zamora Dec 3, 2024
44a1e42
fix tests and add more comments to preserve sanity
carlos-zamora Dec 14, 2024
4764653
simplify and add comment
carlos-zamora Dec 18, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 6 additions & 4 deletions src/cascadia/TerminalCore/TerminalSelection.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -307,12 +307,14 @@ std::pair<til::point, til::point> Terminal::_ExpandSelectionAnchors(std::pair<ti
// GH#5099: We round to the nearest cell boundary,
// so we would normally prematurely expand to the next word
// as we approach it during a 2x-click+drag.
// - !IsWordBoundary(): fixes issue above by prohibiting expanding to the next word if we're at the word boundary
// - start == end: allow word expansion when 2x-clicking word boundary
if (start == end || !buffer.IsWordBoundary(end, _wordDelimiters))
// To remedy this, decrement the end's position by 1.
// However, only do this when expanding right (it's correct
// as is when expanding left).
Comment on lines +310 to +312
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not 100% sure if I understand this code, but to me it feels like the calling code should contain the fix for this and not this function. Is this perhaps just a case of floor VS. ceil in the calling code?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, I'm not happy about this part either. Let me explain what's going on better. The code flow is:

  • ControlInteractivity::SetEndSelectionPoint() (link) - called on mouse drag
    • ControlInteractivity::_getTerminalPosition() (link): round to the nearest cell, that way, we have to drag past a cell to "select" it
  • ControlCore::SetEndSelectionPoint() (link): really just clamps the position to the viewport bounds
  • Terminal::SetSelectionEnd() (link) --> Terminal::_SetSelectionEnd() (link):
    • This is the important part of the code, really. It's where we update our selection state for shift+click, pivoting, and multi-clicks (+ dragging).
    • The issue really only arises when we're multi-clicking+dragging (think "double-click" then drag, as it should expand by word as we drag). So the issue has to do with the expansion part. Anything before that in this function wouldn't make sense to alter, imo.
  • Terminal::_ExpandSelectionAnchors() (link): this is where we actually expand our selection endpoints if we're multi-clicking.

Thankfully, _ExpandSelectionAnchors() is only used in this spot. I'm not sure where else the change would make sense to go though. Open to suggestions.

if (end > _selection->pivot)
{
end = buffer.GetWordEnd2(end, _wordDelimiters, false);
bufferSize.DecrementInExclusiveBounds(end);
}
end = buffer.GetWordEnd2(end, _wordDelimiters, false);
break;
}
case SelectionExpansion::Char:
Expand Down
Loading