feat: chain through forced separators in grammar completion (#467 #343)#478
Open
SJrX wants to merge 1 commit into
Open
feat: chain through forced separators in grammar completion (#467 #343)#478SJrX wants to merge 1 commit into
SJrX wants to merge 1 commit into
Conversation
Accepting a completion now auto-inserts a following forced separator and re-opens
completion, so e.g. accepting "home" yields "home=" and immediately offers the policy
flags — instead of stopping on a single mandatory "=" that the user must type by hand
(and which the platform won't even autopopup since it's a lone punctuation result).
InsertHandler walks the grammar forward from the accepted token: while the only thing
that can come next is a single punctuation separator (",", "=", "+", ":" depending on
grammar), it inserts it; it never auto-inserts a content token the user should choose.
Then it schedules the autopopup. Bounded loop; resolves the value start via PSI.
Test: accepting a partition designator chains the "=" (RootImagePolicy=hom -> home=).
Refs #467 #343
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Test Results1 134 tests 1 134 ✅ 51s ⏱️ Results for commit cbbfef2. |
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.
What
Implements "option 1" from the discussion: when you accept a grammar completion, if the only thing the grammar can accept next is a forced separator, it's auto-inserted and completion re-opens. So accepting
homegives youhome=with the policy-flag popup immediately, instead of stopping on a lone=you'd have to type yourself.Why
After a complete partition designator like
home, the grammar allows exactly one next token:=. A completion popup whose only entry is a single punctuation separator is low-value — and the platform won't even autopopup it (you'd need Ctrl+Space). What the user actually wants next is the policy flag. Chaining through the separator gets them there in one motion (mirrors how method completion inserts()).How
chainingInsertHandlerruns after a choice is accepted:nextTokenChoices(pre)is exactly one punctuation separator (no letters/digits — so=,+,:, never a content token likeverity), insert it and advance. Bounded loop (≤ 8).scheduleAutoPopupso the following real choices (flags) appear.It only ever auto-inserts forced separators, never a content token the user should pick. Applies to all grammar-completion items, so it generalizes to other grammars (
:inipv4:tcp:…, etc.).Test
testAcceptingPartitionChainsTheEqualsSeparator:RootImagePolicy=hom⎉→ accept the single matchhome→ document becomesRootImagePolicy=home=⎉.Full suite green.
Refs #467 #343
🤖 Generated with Claude Code