Skip to content

Commit

Permalink
fix(diagnostic): only set on displayByVimDiagnostic
Browse files Browse the repository at this point in the history
Closes #5242
  • Loading branch information
fannheyward committed Jan 13, 2025
1 parent 674482c commit 9aa7edb
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 19 deletions.
2 changes: 0 additions & 2 deletions src/__tests__/modules/diagnosticManager.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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)
})
})

Expand Down
35 changes: 18 additions & 17 deletions src/diagnostic/buffer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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[] = []
Expand Down Expand Up @@ -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[] = []
Expand All @@ -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)
Expand Down

0 comments on commit 9aa7edb

Please sign in to comment.