Skip to content

Commit bfcbbee

Browse files
committed
lsp: Call workspace/diagnostic/refresh when relevant
Where we would call `sync_diagnostics` in the push model, use the same trigger to send a refresh request to the clients that support it. This should ensure diagnostics are reported in a more timely fashion.
1 parent 14ee51a commit bfcbbee

File tree

1 file changed

+15
-4
lines changed

1 file changed

+15
-4
lines changed

lib/esbonio/esbonio/server/server.py

Lines changed: 15 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -292,14 +292,25 @@ def get_language_at(self, document: TextDocument, position: types.Position) -> s
292292
return ""
293293

294294
def sync_diagnostics(self) -> None:
295-
"""Update the client with the currently stored diagnostics.
295+
"""Update the client with the currently stored diagnostics using
296+
a ``textDocument/publishDiagnostics`` notification.
296297
297-
When the client supports the pull diagnostics model, this is a no-op.
298+
When the client supports the pull diagnostics model, this triggers a
299+
``workspace/diagnostic/refresh`` request instead (if supported by the client).
298300
"""
299-
pull_support = get_capability(
301+
text_diagnostic = get_capability(
300302
self.client_capabilities, "text_document.diagnostic", None
301303
)
302-
if pull_support is not None:
304+
workspace_diagnostic = get_capability(
305+
self.client_capabilities,
306+
"workspace.diagnostics",
307+
types.DiagnosticWorkspaceClientCapabilities(),
308+
)
309+
310+
if text_diagnostic is not None:
311+
if workspace_diagnostic.refresh_support:
312+
# Signal to the client that is should ask again for more diagnostics
313+
self.workspace_diagnostic_refresh(None)
303314
return
304315

305316
uris = {uri for _, uri in self._diagnostics.keys()}

0 commit comments

Comments
 (0)