diff --git a/crates/ty_server/src/server/api/diagnostics.rs b/crates/ty_server/src/server/api/diagnostics.rs index 3d5c16ca01..d43b176a9b 100644 --- a/crates/ty_server/src/server/api/diagnostics.rs +++ b/crates/ty_server/src/server/api/diagnostics.rs @@ -120,7 +120,11 @@ impl LspDiagnostics { /// This is done by notifying the client with an empty list of diagnostics for the document. /// For notebook cells, this clears diagnostics for the specific cell. /// For other document types, this clears diagnostics for the main document. -pub(super) fn clear_diagnostics(key: &DocumentKey, client: &Client) { +pub(super) fn clear_diagnostics(session: &Session, key: &DocumentKey, client: &Client) { + if session.client_capabilities().supports_pull_diagnostics() { + return; + } + let Some(uri) = key.to_url() else { // If we can't convert to URL, we can't clear diagnostics return; diff --git a/crates/ty_server/src/server/api/notifications/did_close.rs b/crates/ty_server/src/server/api/notifications/did_close.rs index 7425b8504e..60097df67b 100644 --- a/crates/ty_server/src/server/api/notifications/did_close.rs +++ b/crates/ty_server/src/server/api/notifications/did_close.rs @@ -65,7 +65,7 @@ impl SyncNotificationHandler for DidCloseTextDocumentHandler { .diagnostic_mode() .is_open_files_only() { - clear_diagnostics(&key, client); + clear_diagnostics(session, &key, client); } } AnySystemPath::SystemVirtual(virtual_path) => { @@ -78,7 +78,7 @@ impl SyncNotificationHandler for DidCloseTextDocumentHandler { // Always clear diagnostics for virtual files, as they don't really exist on disk // which means closing them is like deleting the file. - clear_diagnostics(&key, client); + clear_diagnostics(session, &key, client); } }