Skip to content

Commit

Permalink
fix: delete text should not trigger auto insert
Browse files Browse the repository at this point in the history
close #2222
  • Loading branch information
johnsoncodehk committed Dec 18, 2022
1 parent 877d3c0 commit 087f0fa
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 6 deletions.
6 changes: 1 addition & 5 deletions packages/language-server/src/registerFeatures.ts
Expand Up @@ -74,11 +74,7 @@ export function setupSyntacticCapabilities(
// https://github.com/microsoft/vscode/blob/ce119308e8fd4cd3f992d42b297588e7abe33a0c/extensions/typescript-language-features/src/languageFeatures/formatting.ts#L99
server.documentOnTypeFormattingProvider = {
firstTriggerCharacter: ';',
moreTriggerCharacter: [
'}',
'\n',
'{', // addSpaceBetweenDoubleCurlyBrackets
],
moreTriggerCharacter: ['}', '\n'],
};
}
}
Expand Down
Expand Up @@ -30,7 +30,13 @@ export async function register(
}

function onDidChangeTextDocument({ document, contentChanges, reason }: vscode.TextDocumentChangeEvent) {
if (!isEnabled || contentChanges.length === 0 || reason === vscode.TextDocumentChangeReason.Undo || reason === vscode.TextDocumentChangeReason.Redo) {
if (
!isEnabled
|| contentChanges.length !== 1
|| !contentChanges[0].text // delete
|| reason === vscode.TextDocumentChangeReason.Undo
|| reason === vscode.TextDocumentChangeReason.Redo
) {
return;
}
const activeDocument = vscode.window.activeTextEditor?.document;
Expand Down

0 comments on commit 087f0fa

Please sign in to comment.