Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(diagnostic): only set coc_diagnostic_map on displayByVimDiagnostic #5245

Merged
merged 1 commit into from
Jan 13, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading