From 93f82a96a66e8b76c09d28a2621c968632531334 Mon Sep 17 00:00:00 2001 From: chemzqm Date: Wed, 6 Feb 2019 11:01:42 +0800 Subject: [PATCH] fix duplicated fix for unused variable --- src/server/commands.ts | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/server/commands.ts b/src/server/commands.ts index 463c1a2..a56236a 100644 --- a/src/server/commands.ts +++ b/src/server/commands.ts @@ -1,5 +1,5 @@ import { diagnosticManager, workspace } from 'coc.nvim' -import { CancellationToken } from 'vscode-languageserver-protocol' +import { CancellationToken, Diagnostic } from 'vscode-languageserver-protocol' import URI from 'vscode-uri' import * as Proto from './protocol' import TypeScriptServiceClientHost from './typescriptServiceClientHost' @@ -133,7 +133,13 @@ export class AutoFixCommand implements Command { diagnostics = diagnostics.filter(x => autoFixableDiagnosticCodes.has(x.code as number)) if (diagnostics.length == 0) { workspace.showMessage('No autofixable diagnostics found', 'warning') + return } + diagnostics = diagnostics.reduce((arr, curr) => { + if (curr.code == 2304 && arr.findIndex(o => o.message == curr.message) != -1) return arr + arr.push(curr) + return arr + }, [] as Diagnostic[]) let client = this.client.serviceClient let edits: TextEdit[] = [] for (let diagnostic of diagnostics) {