Skip to content

Fix resource type completion for JSON#453

Open
Ben-Wormald wants to merge 2 commits intoaws-cloudformation:mainfrom
Ben-Wormald:resource-type-completion
Open

Fix resource type completion for JSON#453
Ben-Wormald wants to merge 2 commits intoaws-cloudformation:mainfrom
Ben-Wormald:resource-type-completion

Conversation

@Ben-Wormald
Copy link
Copy Markdown

Issue #, if available: #450

Description of changes:

  • Fix replacement range being set too high
  • Keep object keys when completing values e.g. resource types
  • Simplify JSON formatting function for future improvements

There is still some behaviour for JSON completions that isn't ideal but hopefully this is a first steo to improving it, cheers

By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.

@Ben-Wormald Ben-Wormald requested a review from a team as a code owner February 25, 2026 07:42
@satyakigh
Copy link
Copy Markdown
Collaborator

Hello, thank you for the PR! We will review this soon

fix replacement range being set too high
keep keys when completing values e.g. resource types
simplify JSON formatting function for future improvements
@Zee2413 Zee2413 force-pushed the resource-type-completion branch from ecde3f3 to 6b9a7aa Compare March 2, 2026 19:42
: undefined;
let type: string;

if (section === String(TopLevelSection.Description)) {
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we need to add AWSTemplateFormatVersion here?

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I didn't include it here originally as there's a snippet completion which completes the whole line with "AWSTemplateFormatVersion": "2010-09-09"

However it looks like both that snippet and an object placeholder snippet are suggested, I can take a look at that

@satyakigh
Copy link
Copy Markdown
Collaborator

satyakigh commented Mar 5, 2026

Seems like the build is failing, I think this change potentially introduces some regressions which may or may not have been caught by the removed test(s)

  1. filterText removed (JSON) — Editors send quoted prefixes like "Res" when cursor is inside a JSON string, without filterText, completions won't match

  2. Resource attributes lose type formatting (JSON) — DependsOn, Metadata, CreationPolicy, UpdatePolicy, etc. are created by EntityFieldCompletionProvider with no data.type

  3. Resource type textEdit range removed (YAML) — We set an explicit replacement range via textEdit when the user was partially typing a resource type. With the removal, since resource types contain ::, partial input like AWS::S3::B may get incorrectly replaced, producing AWS::S3::AWS::S3::Bucket

Would love to see some more unit tests around these edge cases

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.

3 participants