-
-
Notifications
You must be signed in to change notification settings - Fork 91
Added scope type for "inside"
#2776
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
Merged
Merged
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
phillco
reviewed
Jan 30, 2025
packages/common/src/scopeSupportFacets/scopeSupportFacetInfos.ts
Outdated
Show resolved
Hide resolved
phillco
reviewed
Jan 30, 2025
packages/common/src/scopeSupportFacets/scopeSupportFacetInfos.ts
Outdated
Show resolved
Hide resolved
phillco
reviewed
Jan 30, 2025
...c/processTargets/modifiers/scopeHandlers/SurroundingPairScopeHandler/InteriorScopeHandler.ts
Outdated
Show resolved
Hide resolved
…andlers/SurroundingPairScopeHandler/InteriorScopeHandler.ts
…into interiorScope
phillco
reviewed
Jan 30, 2025
...c/processTargets/modifiers/scopeHandlers/SurroundingPairScopeHandler/InteriorScopeHandler.ts
Outdated
Show resolved
Hide resolved
…andlers/SurroundingPairScopeHandler/InteriorScopeHandler.ts
phillco
reviewed
Jan 30, 2025
...c/processTargets/modifiers/scopeHandlers/SurroundingPairScopeHandler/InteriorScopeHandler.ts
Outdated
Show resolved
Hide resolved
…andlers/SurroundingPairScopeHandler/InteriorScopeHandler.ts
phillco
reviewed
Jan 30, 2025
- {type: interiorOnly} | ||
usePrePhraseSnapshot: false | ||
initialState: | ||
documentContents: <div>content</div> (hello) |
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.
It would be neat if this would give you this:
<div>|</div> (|)
phillco
approved these changes
Jan 30, 2025
cursorless-bot
pushed a commit
that referenced
this pull request
Jan 30, 2025
Inside/interior today is a modifier and will stay so in the future, but we are also introducing interior as a scope type. This will allow us to do `"take inside"` when on a if statement, python function and so on. It now takes the closest of the nearest tree-sitter interior _or_ surrounding pair. This is most useful for Python; in other languages with {} statement-blocks, the braces would already be easy to target, but now "take inside" behaves intuitively there as well. The scm syntax `@scope.interior` have been replaced by `@interior` as its own scope type. Fixes #1046 ## Checklist - [x] I have added [tests](https://www.cursorless.org/docs/contributing/test-case-recorder/) - [/] I have updated the [docs](https://github.com/cursorless-dev/cursorless/tree/main/docs) and [cheatsheet](https://github.com/cursorless-dev/cursorless/tree/main/cursorless-talon/src/cheatsheet) - [/] I have not broken the cheatsheet ## Release notes You can now use "inside" to refer to the inside body of a language scope (function, if statement, etc). This is especially useful for Python, because previously you had to think about what scope you were targeting -- "take inside" now just works. It also works nicely for targeting the inside of C-style statements that don't have `{}` braces, like single line conditionals or loops. In Python, this also means that you can now target the inside of the function ("take inside") even while the cursor is in a related location (such as in its name). Note that this behavior currently only exists for Python; we plan to port it to other languages as well since it is useful. --------- Co-authored-by: Phil Cohen <[email protected]>
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Inside/interior today is a modifier and will stay so in the future, but we are also introducing interior as a scope type. This will allow us to do
"take inside"
when on a if statement, python function and so on.It now takes the closest of the nearest tree-sitter interior or surrounding pair. This is most useful for Python; in other languages with {} statement-blocks, the braces would already be easy to target, but now "take inside" behaves intuitively there as well.
The scm syntax
@scope.interior
have been replaced by@interior
as its own scope type.Fixes #1046
Checklist
Release notes
You can now use "inside" to refer to the inside body of a language scope (function, if statement, etc). This is especially useful for Python, because previously you had to think about what scope you were targeting -- "take inside" now just works.
It also works nicely for targeting the inside of C-style statements that don't have
{}
braces, like single line conditionals or loops.In Python, this also means that you can now target the inside of the function ("take inside") even while the cursor is in a related location (such as in its name). Note that this behavior currently only exists for Python; we plan to port it to other languages as well since it is useful.