Skip to content

Conversation

@DPrakashh
Copy link

This PR implements snippet completions for control-flow keywords (if, for, while, guard, switch, repeat) when they are used in code completion.

The solution involved updating "CodeCompletionSession.swift" to identify keyword completions (.keyword) and overwrite their "insertText" and "textEdit" with the correct LSP snippet strings, setting the insertTextFormat to .snippet.

This ensures that keywords now contain placeholders (e.g., ${1:condition} and $0) required by LSP clients.

Verification
New unit tests were added to "SwiftCompletionSnippetTests.swift" to explicitly verify:

  1. The "insertTextFormat" is correctly set to ".snippet".
  2. The presence of the required snippet placeholders (e.g., $1, $0).

All local tests, including the focused test (swift test --filter SwiftCompletionSnippetTests/testKeywordIfProvidesSnippet), passed successfully.

Checklist (Based on Contributing Guide)
1-Code has been formatted using `swift format -ipr
2-New tests were added to cover the feature.

@DPrakashh
Copy link
Author

Hi @ahoppen , @bnbarham , @hamishknight , @rintaro

Hope you're having a good week.

I wanted to check on the status of my PR from four days ago. I know these core completion changes take time to review carefully.
Just confirming that all local tests passed on my end. Would it be possible to get the CI tests triggered when a maintainer is able to look at it?

Thanks for your time!

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