Skip to content

Selection Code Cleanup and Double Click Delimiter Runs#2511

Merged
DHowett-MSFT merged 14 commits intomasterfrom
dev/cazamor/misc-selection-tasks
Sep 17, 2019
Merged

Selection Code Cleanup and Double Click Delimiter Runs#2511
DHowett-MSFT merged 14 commits intomasterfrom
dev/cazamor/misc-selection-tasks

Conversation

@carlos-zamora
Copy link
Member

@carlos-zamora carlos-zamora commented Aug 22, 2019

Summary of the Pull Request

Just some housekeeping work on our selection. Added a few more tests and refactored some of the functionality to improve code clarity.

Reenabled x86 tests. They work on my machine. I hope they work on CI?

Added support for double clicking delimiter runs.

Double Click Delimiter runs now operate as follows. Characters are separated into 3 classes:

  • class 0: spaces and control characters
  • class 1: delimiters imported from settings
  • class 2: all other characters
    If you double click a cell, the selection will expand until the class of the next cell differs from the preceding one.

This is slightly different than before in that the following example will only highlight the ">" char instead of the ">" and all the surrounding spaces:

C:\Terminal>
           ^
double click here

References

N/A

PR Checklist

Detailed Description of the Pull Request / Additional comments

Added some testing to ensure we don't crash on out-of-bounds selection anchors.
Consolidated the vertical offset for the anchors since they're always the same.
Broke up GetSelectionRects() into a more clear format with several helper methods.

Validation Steps Performed

All tests pass. I manually did some ALT+selections and regular selections w/ and w/out the scroll area and it still seems fine.

- selectionVerticalOffset
- proper return values (const)
- Break up GetSelectionRects()
@carlos-zamora carlos-zamora self-assigned this Aug 22, 2019
@carlos-zamora carlos-zamora changed the title Add More Selection Testing and Proper Cleanup Selection Code Cleanup and Double Click Delimiter Runs Aug 22, 2019
@carlos-zamora
Copy link
Member Author

carlos-zamora commented Aug 26, 2019

NOTE: Double Click Delimiter runs in this isn't quite right yet. Dustin and I agreed on a new model:
handle delimiter runs as different delimiter classes where...

  • ' ' --> class 0
  • delimiters --> class 1
  • otherwise --> class 2

double clicking a cell containing class I expands the selection to (exclusive) the first non-I class cell in both directions.

This will be implemented in a new branch that targets this one, BUT will (probably) go into master as two different commits. This was easy. New commit covers this. Updating all other things about this PR.

Add test (caught a minor thing because of that)
}
}

TEST_METHOD(SelectToOutOfBounds)
Copy link
Member

Choose a reason for hiding this comment

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

Per some of my comments above, I'd love to see some tests exercising what happens when clearly invalid things are being put into your movement functions like moving left but the left is already left of the viewport.

Copy link
Member

Choose a reason for hiding this comment

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

(also some overflows, probably, given we're using SHORTs here and overflows aren't an impossibility.)

@ghost ghost added the Needs-Author-Feedback The original author of the issue/PR needs to come back and respond to something label Aug 28, 2019
@DHowett-MSFT
Copy link
Contributor

Hey, x86 spontaneously failed! They're all in Griese's App tests though..

@zadjii-msft
Copy link
Member

RPC_S_CALL_FAILED Yea I don't think that's something I caused...

Copy link
Member

@zadjii-msft zadjii-msft left a comment

Choose a reason for hiding this comment

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

Overall seems good, kinda minor nits from me

@ghost ghost removed the Needs-Author-Feedback The original author of the issue/PR needs to come back and respond to something label Aug 28, 2019
Copy link
Member

@zadjii-msft zadjii-msft left a comment

Choose a reason for hiding this comment

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

I'm definitely happier with this now

@ghost ghost added the Needs-Author-Feedback The original author of the issue/PR needs to come back and respond to something label Sep 4, 2019
@ghost ghost removed the Needs-Author-Feedback The original author of the issue/PR needs to come back and respond to something label Sep 9, 2019
remove some const return values that are unneccesary
// - the selection row needed for rendering
SMALL_RECT Terminal::_GetSelectionRow(const SHORT row, const COORD higherCoord, const COORD lowerCoord) const
{
SMALL_RECT selectionRow;
Copy link

Choose a reason for hiding this comment

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

nit: Even though each member of SMALL_RECT gets set currently it is best practice to always initialize a struct. I am not sure what the team's stance is on this though.

SMALL_RECT selectionRow{0};

Add/Fix Tests
Copy link
Member

@miniksa miniksa left a comment

Choose a reason for hiding this comment

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

Approved with minor nits.

@DHowett-MSFT DHowett-MSFT dismissed their stale review September 17, 2019 17:35

Lots of changes.

@DHowett-MSFT DHowett-MSFT merged commit 4217bed into master Sep 17, 2019
@DHowett-MSFT DHowett-MSFT deleted the dev/cazamor/misc-selection-tasks branch September 17, 2019 17:39
@ghost
Copy link

ghost commented Sep 24, 2019

🎉Windows Terminal Preview v0.5.2661.0 has been released which incorporates this pull request.:tada:

Handy links:

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

5 participants