Skip to content

Commit

Permalink
fix: avoid response InsertReplaceEdit when insertReplaceSupport false
Browse files Browse the repository at this point in the history
close #1373
  • Loading branch information
johnsoncodehk committed Jun 2, 2022
1 parent b10f636 commit 271a587
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion packages/vue-language-server/src/features/languageFeatures.ts
Expand Up @@ -44,9 +44,18 @@ export function register(
: undefined;
const newPosition = activeSel?.textDocument.uri.toLowerCase() === uri.toLowerCase() ? activeSel.position : undefined;

return await worker(uri, async vueLs => {
const result = await worker(uri, async vueLs => {
return vueLs.doCompletionResolve(item, newPosition) ?? item;
}) ?? item;

const insertReplaceSupport = params.capabilities.textDocument?.completion?.completionItem?.insertReplaceSupport ?? false;
if (!insertReplaceSupport) {
if (result.textEdit && vscode.InsertReplaceEdit.is(result.textEdit)) {
result.textEdit = vscode.TextEdit.replace(result.textEdit.insert, result.textEdit.newText);
}
}

return result;
});
connection.onHover(async handler => {
return worker(handler.textDocument.uri, vueLs => {
Expand Down

0 comments on commit 271a587

Please sign in to comment.