Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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
Contiguous scope #2101
base: main
Are you sure you want to change the base?
Contiguous scope #2101
Changes from 28 commits
fdcd03e
f223d84
b549ca5
a71f017
da8d6ec
a3fa351
53351e8
d370690
48f97ee
e2ec5c8
d1020a8
02a295e
9d75ead
48c7a65
fa57ab2
c943542
c26d704
e0b6b5b
2988adb
c2f942b
34cbbb1
8b5a95f
bd86a64
5a905ea
6612818
2852e37
d3eb687
fe7e8e5
2f15dc6
0ccdcc6
fd93230
d898f26
ea5a542
66731e4
58bfb9a
b6ac60f
17b0507
6f0de5c
9f156a6
38ab206
883eb1e
File filter
Filter by extension
Conversations
Jump to
There are no files selected for viewing
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'm not convinced this function is correct. Eg corner cases like single scope not adjacent to others that's last in the file. To me it looks like if you've already yielded anything, then the final yield after the loop body won't fire.
Some proper unit tests for
ContiguousScopeHandler
would help. See https://github.com/cursorless-dev/cursorless/blob/main/packages/cursorless-engine/src/processTargets/modifiers/scopeHandlers/BaseScopeHandler.test.ts if you're not sure how to do unit tests for this kinda thing. There's a limit to how far you can get using existing scopesThere 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.
Actually might make sense to hold off on unit tests for the following reasons:
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.
Update from discussion today:
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.
looking at these test cases, i think it should die
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.
Sounds good. Any opinion on making single-line comments behave this way by default? (Ie auto expand to all comments that aren't separated by an empty line)
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.
Update from meet-up: let's do the following:
( (comment) @comment (#match? @comment "^//") (#contiguous! @comment) ) (comment) @comment
We both don't love this option or the option in this PR, but it's the best we can do with what we have today. Fwiw we would prefer something like
( (comment) @comment ($if (#match? @comment "^//") (#contiguous! @comment) ) )
but that's a bit out of scope here 😅
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.
This file is now general enough to be used with most scopes. If we wanted to we could remove a bunch of code here and rely on the fact that we only use it for comments. I could go either way.
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.
do we want to throw an error if there's more than one target? Should we have a utility function
function ensureSingleTarget(scope: Scope): Target
that checks there's only one target and returns it? That worked out well forensureSingleEditor
I thinkThere 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.
Reused our existing and shore single target. They should really never trigger with our current implementation so am fine with using an error message that might not be perfect.