Skip to content

Commit baac60a

Browse files
authored
fix(diagnostic): only set on displayByVimDiagnostic (#5245)
Closes #5242
1 parent 674482c commit baac60a

File tree

2 files changed

+18
-19
lines changed

2 files changed

+18
-19
lines changed

src/__tests__/modules/diagnosticManager.test.ts

-2
Original file line numberDiff line numberDiff line change
@@ -687,8 +687,6 @@ describe('diagnostic manager', () => {
687687
await manager.toggleDiagnosticBuffer(doc.bufnr, 1)
688688
res = await buf.getVar('coc_diagnostic_info') as any
689689
expect(res.error).toBe(2)
690-
let items = await buf.getVar('coc_diagnostic_map') as any
691-
expect(items.length).toBe(5)
692690
})
693691
})
694692

src/diagnostic/buffer.ts

+18-17
Original file line numberDiff line numberDiff line change
@@ -420,7 +420,7 @@ export class DiagnosticBuffer implements SyncItem {
420420
nvim.resumeNotification(true, true)
421421
} else if (displayByVimDiagnostic) {
422422
nvim.pauseNotification()
423-
this.setDiagnosticInfo()
423+
this.setDiagnosticInfo(true)
424424
nvim.resumeNotification(true, true)
425425
} else {
426426
let emptyCollections: string[] = []
@@ -485,7 +485,7 @@ export class DiagnosticBuffer implements SyncItem {
485485
this.nvim.call('coc#ui#update_signs', [this.bufnr, group, signs], true)
486486
}
487487

488-
public setDiagnosticInfo(): void {
488+
public setDiagnosticInfo(full = false): void {
489489
let lnums = [0, 0, 0, 0]
490490
let info = { error: 0, warning: 0, information: 0, hint: 0, lnums }
491491
let items: DiagnosticItem[] = []
@@ -510,21 +510,22 @@ export class DiagnosticBuffer implements SyncItem {
510510
info.error = info.error + 1
511511
}
512512

513-
let { start, end } = diagnostic.range
514-
items.push({
515-
file: URI.parse(this.doc.uri).fsPath,
516-
lnum: start.line + 1,
517-
end_lnum: end.line + 1,
518-
col: start.character + 1,
519-
end_col: end.character + 1,
520-
code: diagnostic.code,
521-
source: diagnostic.source,
522-
message: diagnostic.message,
523-
severity: getSeverityName(diagnostic.severity),
524-
level: diagnostic.severity ?? 0,
525-
location: Location.create(this.doc.uri, diagnostic.range)
526-
527-
})
513+
if (full) {
514+
let { start, end } = diagnostic.range
515+
items.push({
516+
file: URI.parse(this.doc.uri).fsPath,
517+
lnum: start.line + 1,
518+
end_lnum: end.line + 1,
519+
col: start.character + 1,
520+
end_col: end.character + 1,
521+
code: diagnostic.code,
522+
source: diagnostic.source,
523+
message: diagnostic.message,
524+
severity: getSeverityName(diagnostic.severity),
525+
level: diagnostic.severity ?? 0,
526+
location: Location.create(this.doc.uri, diagnostic.range)
527+
})
528+
}
528529
}
529530
}
530531
let buf = this.nvim.createBuffer(this.bufnr)

0 commit comments

Comments
 (0)