address feedback

Kunall Banerjee created

Change summary

crates/project/src/lsp_store.rs | 13 ++++++++++---
1 file changed, 10 insertions(+), 3 deletions(-)

Detailed changes

crates/project/src/lsp_store.rs 🔗

@@ -6587,9 +6587,16 @@ impl LspStore {
             **lsp_completion = resolved_completion;
             *resolved = true;
 
-            // Re-derive new_text from the resolved completion. Some servers
-            // (e.g. vtsls with completeFunctionCalls) update insertText/textEdit
-            // during resolve to add snippet content like function call parentheses.
+            // We must not use any data such as sortText, filterText, insertText and textEdit to edit `Completion` since they are not supposed to change during resolve.
+            // Refer: https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification/#textDocument_completion
+            //
+            // We still re-derive new_text here as a workaround for the specific
+            // VS Code TypeScript completion resolve flow that vtsls wraps:
+            // https://github.com/microsoft/vscode/blob/838b48504cd9a2338e2ca9e854da9cec990c4d57/extensions/typescript-language-features/src/languageFeatures/completions.ts#L218
+            //
+            // Some servers (e.g. vtsls with completeFunctionCalls) update
+            // insertText/textEdit during resolve to add snippet content like
+            // function call parentheses.
             //
             // vtsls resolve flow:
             //   https://github.com/yioneko/vtsls/blob/fecf52324a30e72dfab1537047556076720c1a5f/packages/service/src/service/completion.ts#L228-L244