-
-
Notifications
You must be signed in to change notification settings - Fork 84
Automatically try to remove scopes as if they're token, line, block, file if they have no removal behaviour #855
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
Comments
Do you want this behavior only for pour or also for bring? Should some scopes types be omitted? Because now when we have textual item scope |
If something is the last token on the line it will not count as a line. It needs to start and end on line boundary It will also only be if the scope type has no explicit delimiter set, so wouldn't affect item for that reason as well |
I guess for scope types that have no specific insertion delimiter this could work. How will you handle multiline targets? Check both first and last line? Leading and trailing white space will be omitted from the line calculation? |
Yep! |
I think we can also consider detecting we're a block and set it to |
This one is also super annoying for "section" in markdown, eg "clone up section" |
The current solution for these is of course that they have the wrong delimiter. Section should definitely not insert or remove as a token. |
Yeah maybe for now let's just add them to that switch statement, but I do worry it's going to start feeling like a game of whack-a-mole |
Agreed. We should definitely have a proper look at an alternative solution. But just for now I think we should just add them to the delimiter list. |
Fixes #855 ## Checklist - [ ] 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 --------- Co-authored-by: Phil Cohen <[email protected]>
Most of our tree-sitter scopes don't remove newlines, and some of them don't remove spaces. We'd like a way to make them all automatically remove the appropriate whitespace
I would argue that we should detect if something stops at a line boundary and use newline delimiter if so.
Implementation
Where
Let's start by putting it on
SyntacticScopeTarget
What
If target has leading or trailing range, we use today's behaviour.
Otherwise, we see if the "core removal range" corresponds to the entire file, then falling back to block, then line, then token. If it corresponds to one of these, we forward calls to
removalRange
to the upgraded targetThe core removal range will be the value passed in to
removalRange
in constructor, otherwise content range.Other thoughts
Alternately we could add this implementation to
BaseTarget
, so that things likeSyntacticScopeTarget
will get it, but not getLineTarget
,TokenTarget
,UntypedTarget
(?) will override it, but let's start withSyntacticScopeTarget
for nowThe text was updated successfully, but these errors were encountered: