-
Notifications
You must be signed in to change notification settings - Fork 8.4k
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
Chunk Selection Expansion for Double/Triple Click Selection #2184
Conversation
@@ -63,6 +63,19 @@ std::vector<SMALL_RECT> Terminal::_GetSelectionRects() const | |||
selectionRow.Right = (row == lowerCoord.Y) ? lowerCoord.X : bufferSize.RightInclusive(); | |||
} | |||
|
|||
// expand selection for Double/Triple Click | |||
if (multiClickSelectionMode == selectionExpansionMode::Word && _selectionAnchor != _endSelectionPosition) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think I'd really love to see some extra tests added for this in the TerminalCore tests.
#Resolved |
{ | ||
return viewportPos; | ||
THROW_HR(E_INVALIDARG); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
y new except
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Theoretically, we should never hit this case. But, if somebody somehow did a double click OUTSIDE of the terminal, I think it makes sense to clamp it to the nearest valid buffer cell. So how does this sound?
positionWithOffsets.X = std::clamp(viewportPos.X, static_cast<SHORT>(0), _buffer->GetSize().RightInclusive());
positionWithOffsets.Y = std::clamp(viewportPos.Y, static_cast<SHORT>(0), _buffer->GetSize().BottomInclusive());
Note that this is explicitly should not be clamped to the viewport to allow for selections outside of the region we can see. This mainly affects scroll interactions (i.e.: auto scroll, scrolling into an existing selection, etc...).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
SA is out of disk space. |
🎉 Handy links: |
Summary of the Pull Request
Double/Triple click create a selection expanding beyond one cell. This PR makes it so that when you're dragging your mouse to expand the selection, you expand to the next delimiter defined by double/triple click.
So, double click expands by doubleClickDelimiter ranges. Triple click expands by line.
When you double/triple click, a word/line is selected. When you drag, that word/line will remain selected after the expansion occurs.
References
PR Checklist
added/passednot necessaryDetailed Description of the Pull Request / Additional comments
Rather than resizing the selection when the mouse event occurs, I figured I'd do what I did with wide glyph selection: expand at render time.
We needed an enum
multiClickSelectionMode
to keep track of which expansion mode we're in.Minor modifications to
_ExpandDoubleClickSelection*(COORD)
had to be made so that we can re-use them.Actual expansion occurs in
_GetSelectionRects()
Validation Steps Performed
dir
orls
dir
orls
dir
orls
dir
orls
repeat above tests in following scenarios: