Complete inside the object a key is being typed into - #434
Open
holodorum wants to merge 2 commits into
Open
Conversation
Completion at a fresh `- ` offered the enclosing object's properties
rather than the item's. AstNodeWalker dropped list elements in error,
so the caret could not be located any deeper than the list itself, and
parentCaretPath then dropped a segment to reach the list's parent.
A list element is addressed by its index, so an element in error now
stands among its siblings as a leaf -- dropping it renumbered the
elements after it as well. And a list dash joins `[`, `{` and `<` as a
token that opens the value the caret sits in, so the pointer keeps the
item index navigation just found.
With the item reachable, the placeholder that compensated for the old
behaviour goes: a fresh item no longer borrows its enclosing property's
span, because the item's own span is the value being authored.
A key with no `:` yet is not a keyword, so an undelimited object ends at it and it becomes trailing content -- the language's rule, not a gap in it. Completion then could not find the caret in the tree and fell back to the root schema, so typing a key into a nested object offered the root's properties instead of that object's. A token the parser never placed says nothing about scope, so resolve from the last token that is in the tree, as if the caret sat in the whitespace just after it, and let the existing drop-to-parent case do the rest. A key can only belong to an object, and the language agrees: `other` after an unterminated dash list parses as a property of the object owning that list. So when the last placed token is a list element, the path keeps walking out while it names a list.
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
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.
Typing a property key inside an undelimited object offered the root schema's completions instead of the object's. A key with no
:yet is not a keyword, so the object ends at it and everything from there is trailing content.The problem was in the caret resolver: it navigated from the half-typed key, found it outside the tree, and fell back to the root pointer.
A second, related fix: completion at a fresh
-offered the enclosing object's properties rather than the item's values.AstNodeWalkerdropped list elements in error, which both hid the caret's target and renumbered every element after it, so an element in error now stands among its siblings as a leaf. With the item addressable, the placeholder machinery that compensated for it (a fresh item borrowing its enclosing property's span) is deleted.