Take the ancestor path into account when env-completing from uncles. #1661
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.
Consider the following input, which I think follows a pretty common pattern:
(with
‸
denoting the cursor). This will use env completion, getting possible completions from the parent nodes in the AST, along with the "great-uncle" node{foo.bar.baz | default = 1}
. So we should offer thebar
completion because it's defined in the parent record. But we should also includebaz
as a completion because our great-uncle definesfoo.bar.baz
and our path relative to our grandparent isfoo.bar
.This PR implements some extra path tracking when traversing the parent chain, adding these extra completions.
As an extra small thing, it discards completions if their only occurence is at the cursor itself. This prevents us from offering
ba
as a completion in the example above.