Delay squiggles - #3545
Conversation
300ms when idle, 1500ms during active typing. Squiggles for documents other than the one being edited refresh immediately. When the squiggle count drops to zero, refresh immediately. Note: Does not affect computation of squiggles - only display.
There was a problem hiding this comment.
Pull request overview
This PR adds a debounced “diagnostics publisher” so the VS Code extension can delay displaying squiggles for the actively edited document (while still computing diagnostics as before), reducing churn during typing.
Changes:
- Introduces a
DiagnosticsPublisherutility in theqsharp-langnpm package to debounce publishing for a single “hot” document with an idle delay and a maximum cap. - Integrates
DiagnosticsPublisherinto the VS Code language-service diagnostics pipeline and tracks the “hot” document based on text-change events. - Adds node-based unit tests for
DiagnosticsPublisherand exports the new utility/types from the npm package entrypoint.
Reviewed changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
| source/vscode/src/language-service/diagnostics.ts | Wraps diagnostic publishing with DiagnosticsPublisher and tracks the hot document from VS Code edit events. |
| source/npm/qsharp/test/diagnosticsPublisher.test.mjs | Adds focused unit tests verifying debounce/cap/flush/dispose behavior. |
| source/npm/qsharp/src/main.ts | Exports DiagnosticsPublisher and DiagnosticsPublisherOptions from the public npm API. |
| source/npm/qsharp/src/language-service/diagnosticsPublisher.ts | Implements the debounced publisher logic (idle delay + max cap + immediate publish when cleared). |
|
Offline copilot review found that the delays are based on diagnostic events, rather than edit events. Re-evaluating (though it seems to work well in practice). |
|
We're reporting the same diagnostics as before, just later. The main consequence I can think of is that VS Code has some handling for stale squiggles - if you type within a squiggled span, the squiggle will expand to accommodate the new characters. We're losing that (for edits within a brief window) but the whole point of the change is to not have squiggles around the cursor while typing, so I think that's acceptable. |
300ms when idle, 1500ms during active typing.
Squiggles for documents other than the one being edited refresh immediately. When the squiggle count drops to zero, refresh immediately.
Note: Does not affect computation of squiggles - only display.
Note: Doesn't affect the playground, which is deliberately bare-bones.
Caveat: Basically doesn't work without #3534 because the
setTimeouts get starved.