-
-
Notifications
You must be signed in to change notification settings - Fork 84
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
Collection item scope provider #2683
Conversation
@@ -27,11 +27,10 @@ finalState: | |||
|
|||
{ | |||
, | |||
;; 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.
NTS: This is an example of the new code performing worse, but we understand why. This is because textual scope defines the item as:
;; hello
:baz "whatever",
In this case the language does identify that the comment is not part of the item, but we are preferring the textual scope, and as above, we no longer blind take the language server's view.
This will affect every language will you have an inline comment next to an item, we just don't have many tests in our more common languages that show that. There's an issue for improving the handling of comments around items. (Might be #1770?). It's a complex change.
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.
NB: the newer code uses more queries and predicates and less imperative TypeScript, so it's also something that would have been easier to monkey patch in the older code, although arguably, for a worse long term outcome
:bongo { | ||
:foo "bar", | ||
, | ||
} | ||
} |
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.
NTS: the old behavior was interesting: the cursor was on the comment so presumably the language server returned the entire :bongo item as the "item".
With the new behavior the textual scope includes the comment as part of the next item (see other thread), which is generally slightly worse, but in this case leads to a better outcome.
@@ -21,7 +21,7 @@ initialState: | |||
start: {line: 0, character: 2} | |||
end: {line: 0, character: 5} | |||
finalState: | |||
documentContents: "{ :baz \"whatever\"}" | |||
documentContents: "{}" |
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.
NTS: this outcome is worse but there's not much we can do about it at the current time. Problem is that closure does not use explicit list delimiters and the textual base system can obviously not figure out if a space is part of an item or a separator here. The textual system thinks the entire :foo "bar" :baz "whatever"
is one "item".
Andreas' idea: allow a language to specify whether it uses explicit delimiters for lists, and if it does not, go back to the old implementation of always taking the language servers opinion.
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.
;; 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.
Same as the other ones
|
||
|
||
[#2 Range] = 1:4-1:19 | ||
>---------------< |
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 syntax is indicating where Cursorless might search for items (Andreas says: that's the definition of iteration scope), although not necessarily were they could be returned. The >/< are not part of the range.
[#1 Range] = | ||
[#1 Domain] = 0:8-0:8 | ||
>< | ||
0| def foo(): |
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.
NB: this range is technically empty. We don't consider it worthwhile to omit empty ranges from this test file.
Andreas says: conceivably it could be useful to be able to bootstrap an empty list by saying "pour item" and targeting this range, so empty ranges are not necessarily useless.
1| global bar, baz | ||
|
||
|
||
[#3 Range] = 1:11-1:19 |
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.
NB: this is the old range from the language server, it's not marked as such, but you know because it's identical to the old code
[#2 Domain] = 1:0-1:19 | ||
>-------------------< | ||
1| global bar, baz |
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 domain is extra but we know from the previous code it will be eliminated when items are actually requested (global
will be whittled away).
The intent of this type of test file is just to show the iteration search scopes, so this is proper.
@@ -2,12 +2,12 @@ import foo, bar | |||
--- | |||
|
|||
[#1 Content] = | |||
[#1 Domain] = 0:7-0:10 | |||
>---< | |||
[#1 Domain] = 0:0-0:10 |
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.
NB: 1 on the right side is new; the old 1 has become 2, the old 2 has become 3
The new one here is the extra scope generated by the textual source.
As above this won't actually change behavior because when items are actually specifically requested we are going to end up the same list, import
won't be included
< | ||
|
||
|
||
[#2 Range] = 1:4-1:6 |
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.
NB: all of these ranges are from the textual source
|
||
[#1 Removal] = 0:1-0:4 | ||
>---< | ||
0| [1, "2, 3"] |
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 is specific logic to discard stuff inside of strings (text fragments)
packages/cursorless-engine/src/processTargets/modifiers/scopeHandlers/OneOfScopeHandler.ts
Outdated
Show resolved
Hide resolved
…andlers/OneOfScopeHandler.ts
...e/src/processTargets/modifiers/scopeHandlers/CollectionItemScopeHandler/createTargetScope.ts
Outdated
Show resolved
Hide resolved
…andlers/CollectionItemScopeHandler/createTargetScope.ts
Fix some of the clojure collection item regression from #2683 Related #2723 ## 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
Fixes #1059
Related #1052
Checklist