You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
fix: JSON resource type value completion formatted as key (#520)
* fix: JSON resource type value completion formatted as key
CompletionFormatter.formatForJson treated all completions as key
insertions — wrapping in quotes with trailing colon and replacing
from column 0. This broke resource type value completion in JSON
(e.g. typing AWS::S3::B inside "Type": "") because:
1. newText was '"AWS::S3::Bucket":' (colon appended to value)
2. textEdit range started at column 0, wiping out the "Type" key
3. filterText was '"AWS::S3::Bu"' which editors couldn't match
Fix: detect value completions via CompletionItemKind.Class (used
exclusively for resource types) and replace only the quoted value
token with the correct text.
Also fixes debug_tree.ts crash on undefined cfnFileType.
Adds e2e and unit tests for JSON resource type value completion.
* refactor: use syntax tree to detect JSON value position
Replace item.kind === CompletionItemKind.Class check with proper
syntax tree inspection. A node is a value completion when it is
the value child of a pair node in the JSON tree-sitter AST:
node.parent?.type === 'pair' && parent.childForFieldName('value') === node
This is more precise than checking item.kind since
TopLevelSectionCompletionProvider also uses CompletionItemKind.Class
for key completions.
* test: add e2e test for JSON enum value completion
Adds test for DeletionPolicy enum values in JSON templates.
This was also affected by the value formatting bug.
* refactor: move JSON value detection to Context.isJsonPairValue()
Add isJsonPairValue() to Context that uses the tree-sitter pair
node structure to reliably detect value positions in JSON. A node
is a value when it is the value child of a pair node.
This is consistent with how YAML key/value detection works in
Context (using synthetic nodes) and avoids relying on item.kind
or the unreliable propertyPath heuristic for JSON.
0 commit comments