Skip to content

Complete inside the object a key is being typed into - #434

Open
holodorum wants to merge 2 commits into
kson-org:mainfrom
holodorum:completion-inside-plain-objects
Open

Complete inside the object a key is being typed into#434
holodorum wants to merge 2 commits into
kson-org:mainfrom
holodorum:completion-inside-plain-objects

Conversation

@holodorum

Copy link
Copy Markdown
Collaborator

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. AstNodeWalker dropped 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.

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.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant