Skip to content

Commit 967ec28

Browse files
committed
fix: debounce LSP diagnostics to get complete results
1 parent 34024c2 commit 967ec28

1 file changed

Lines changed: 9 additions & 3 deletions

File tree

packages/opencode/src/lsp/client.ts

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -188,20 +188,26 @@ export namespace LSPClient {
188188
)
189189
log.info("waiting for diagnostics", { path: normalizedPath })
190190
let unsub: () => void
191+
let debounceTimer: ReturnType<typeof setTimeout> | undefined
191192
return await withTimeout(
192193
new Promise<void>((resolve) => {
193194
unsub = Bus.subscribe(Event.Diagnostics, (event) => {
194195
if (event.properties.path === normalizedPath && event.properties.serverID === result.serverID) {
195-
log.info("got diagnostics", { path: normalizedPath })
196-
unsub?.()
197-
resolve()
196+
// Debounce to allow LSP to send follow-up diagnostics (e.g., semantic after syntax)
197+
if (debounceTimer) clearTimeout(debounceTimer)
198+
debounceTimer = setTimeout(() => {
199+
log.info("got diagnostics", { path: normalizedPath })
200+
unsub?.()
201+
resolve()
202+
}, 150)
198203
}
199204
})
200205
}),
201206
3000,
202207
)
203208
.catch(() => {})
204209
.finally(() => {
210+
if (debounceTimer) clearTimeout(debounceTimer)
205211
unsub?.()
206212
})
207213
},

0 commit comments

Comments
 (0)