Repository navigation
Add a workaround for forcing keepWhitespace=true for snippet edits from the server - #6121
Conversation
…om the server Fixes #6120
There was a problem hiding this comment.
Code Review
This pull request introduces a custom implementation of asWorkspaceEdit (named asWorkspaceEditWithKeepWhitespaceSnippets) in the LSP analyzer to ensure keepWhitespace is set to true on SnippetTextEdits, preventing VS Code from altering indentation. It also updates related tests to accommodate these changes. The review feedback highlights two important issues: first, SnippetTextEdit.snippet is a string in the LSP specification, meaning edit.snippet.value will evaluate to undefined; second, the item parameter in asCodeAction should be typed as ls.CodeAction | undefined | null to match the p2c.asCodeAction signature and prevent TypeScript compilation errors.
Important
The consumer version of Gemini Code Assist on GitHub is being sunset. Starting June 18, 2026, new organization installations will be blocked, and all code review activity will officially cease on July 17, 2026.
For more details on the timeline and next steps, please review the Help Documentation.
There was a problem hiding this comment.
Pull request overview
This PR introduces a client-side workaround in the Dart-Code VS Code extension to ensure snippet-based workspace edits preserve indentation by forcing keepWhitespace=true on SnippetTextEdits converted from LSP responses, addressing the whitespace regression described in #6120.
Changes:
- Overrides the LSP client’s internal protocol-to-code workspace edit conversion to set
SnippetTextEdit.keepWhitespace = true. - Routes code actions’
editconversion through the custom workspace edit converter. - Adjusts an assist code action provider test to account for legacy vs new snippet edit behaviors.
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 4 comments.
| File | Description |
|---|---|
| src/extension/analysis/analyzer.ts | Adds a custom workspace edit converter to force keepWhitespace=true for snippet edits and wires it into code action conversion. |
| src/test/flutter/providers/assist_code_action_provider.test.ts | Updates the snippet-related test to handle legacy vs inline-edit code action results. |
| src/extension/analysis/analyzer_snippet_text_edits.ts | Minor whitespace-only cleanup. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## master #6121 +/- ##
==========================================
- Coverage 71.18% 71.11% -0.07%
==========================================
Files 170 170
Lines 13096 13124 +28
Branches 2633 2642 +9
==========================================
+ Hits 9322 9333 +11
- Misses 3263 3274 +11
- Partials 511 517 +6 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
Fixes #6120