From 9aa7edbf58aa6df5d8b8f35340a8a8773c774e17 Mon Sep 17 00:00:00 2001 From: Heyward Fann Date: Mon, 13 Jan 2025 09:34:25 +0800 Subject: [PATCH] fix(diagnostic): only set on displayByVimDiagnostic Closes #5242 --- .../modules/diagnosticManager.test.ts | 2 -- src/diagnostic/buffer.ts | 35 ++++++++++--------- 2 files changed, 18 insertions(+), 19 deletions(-) diff --git a/src/__tests__/modules/diagnosticManager.test.ts b/src/__tests__/modules/diagnosticManager.test.ts index 4e4f9ee89fa..ac56d843976 100644 --- a/src/__tests__/modules/diagnosticManager.test.ts +++ b/src/__tests__/modules/diagnosticManager.test.ts @@ -687,8 +687,6 @@ describe('diagnostic manager', () => { await manager.toggleDiagnosticBuffer(doc.bufnr, 1) res = await buf.getVar('coc_diagnostic_info') as any expect(res.error).toBe(2) - let items = await buf.getVar('coc_diagnostic_map') as any - expect(items.length).toBe(5) }) }) diff --git a/src/diagnostic/buffer.ts b/src/diagnostic/buffer.ts index cfaeabd8bf8..be4964f048a 100644 --- a/src/diagnostic/buffer.ts +++ b/src/diagnostic/buffer.ts @@ -420,7 +420,7 @@ export class DiagnosticBuffer implements SyncItem { nvim.resumeNotification(true, true) } else if (displayByVimDiagnostic) { nvim.pauseNotification() - this.setDiagnosticInfo() + this.setDiagnosticInfo(true) nvim.resumeNotification(true, true) } else { let emptyCollections: string[] = [] @@ -485,7 +485,7 @@ export class DiagnosticBuffer implements SyncItem { this.nvim.call('coc#ui#update_signs', [this.bufnr, group, signs], true) } - public setDiagnosticInfo(): void { + public setDiagnosticInfo(full = false): void { let lnums = [0, 0, 0, 0] let info = { error: 0, warning: 0, information: 0, hint: 0, lnums } let items: DiagnosticItem[] = [] @@ -510,21 +510,22 @@ export class DiagnosticBuffer implements SyncItem { info.error = info.error + 1 } - let { start, end } = diagnostic.range - items.push({ - file: URI.parse(this.doc.uri).fsPath, - lnum: start.line + 1, - end_lnum: end.line + 1, - col: start.character + 1, - end_col: end.character + 1, - code: diagnostic.code, - source: diagnostic.source, - message: diagnostic.message, - severity: getSeverityName(diagnostic.severity), - level: diagnostic.severity ?? 0, - location: Location.create(this.doc.uri, diagnostic.range) - - }) + if (full) { + let { start, end } = diagnostic.range + items.push({ + file: URI.parse(this.doc.uri).fsPath, + lnum: start.line + 1, + end_lnum: end.line + 1, + col: start.character + 1, + end_col: end.character + 1, + code: diagnostic.code, + source: diagnostic.source, + message: diagnostic.message, + severity: getSeverityName(diagnostic.severity), + level: diagnostic.severity ?? 0, + location: Location.create(this.doc.uri, diagnostic.range) + }) + } } } let buf = this.nvim.createBuffer(this.bufnr)