From bffc00e6683b53fe2808eb57b2a527ce1c2fbc83 Mon Sep 17 00:00:00 2001 From: chemzqm Date: Thu, 6 Jun 2019 12:44:05 +0800 Subject: [PATCH] fix wrong replace --- src/server/features/completionItemProvider.ts | 2 +- src/server/organizeImports.ts | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/server/features/completionItemProvider.ts b/src/server/features/completionItemProvider.ts index fc35ccc..d5bc697 100644 --- a/src/server/features/completionItemProvider.ts +++ b/src/server/features/completionItemProvider.ts @@ -300,7 +300,7 @@ export default class TypeScriptCompletionItemProvider implements CompletionItemP if (additionalTextEdits.length && this.noSemicolons) { // remove comma additionalTextEdits.forEach(o => { - o.newText = o.newText.replace(/;(?:(\n|$))/g, '') + o.newText = o.newText.replace(/;(?=(\n|$))/g, '') }) } return { diff --git a/src/server/organizeImports.ts b/src/server/organizeImports.ts index 6675bd6..302eeb0 100644 --- a/src/server/organizeImports.ts +++ b/src/server/organizeImports.ts @@ -50,7 +50,7 @@ export class OrganizeImportsCommand implements Command { if (changes) { for (let c of Object.keys(changes)) { for (let textEdit of changes[c]) { - textEdit.newText = textEdit.newText.replace(/;(?:(\n|$))/g, '') + textEdit.newText = textEdit.newText.replace(/;(?=(\n|$))/g, '') } } }