[ty] Add capabilities check for clear_diagnostics (#20989)

This commit is contained in:
Takayuki Maeda 2025-10-21 02:31:01 +09:00 committed by GitHub
parent a7c38eb122
commit 1197035c02
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 7 additions and 3 deletions

View file

@ -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;

View file

@ -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);
}
}