-
Notifications
You must be signed in to change notification settings - Fork 39.3k
editor.insertSnippet() messes with indenting of the SnippetString #63129
Copy link
Copy link
Closed
Labels
apifeature-requestRequest for new features or functionalityRequest for new features or functionalityhelp wantedIssues identified as good community contribution opportunitiesIssues identified as good community contribution opportunitiesinsiders-releasedPatch has been released in VS Code InsidersPatch has been released in VS Code Insiderson-release-notesIssue/pull request mentioned in release notesIssue/pull request mentioned in release notessnippetsverifiedVerification succeededVerification succeeded
Milestone
Metadata
Metadata
Assignees
Labels
apifeature-requestRequest for new features or functionalityRequest for new features or functionalityhelp wantedIssues identified as good community contribution opportunitiesIssues identified as good community contribution opportunitiesinsiders-releasedPatch has been released in VS Code InsidersPatch has been released in VS Code Insiderson-release-notesIssue/pull request mentioned in release notesIssue/pull request mentioned in release notessnippetsverifiedVerification succeededVerification succeeded
This is a very similar issue to #44200/#57093 but that fix appears to be only being applied to completions, but applying snippets causes the same issues.
Here's a repro:
This creates a doc and inserts into it the code:
It then applies a snippet string that includes an additional line that is also indented by two spaces. However what you end up with is:
The inserted line has been re-indented.
Whilst this behaviour may be useful if applying basic hard-coded strings, it's incorrect for language servers that are correctly calculating edits to leave the file indented/formatted correctly (I guess for the same reasons that left to #57093).