add capabilities check for `clear_diagnostics_for_document`

This commit is contained in:
Takayuki Maeda 2025-11-02 04:13:06 +09:00
parent 17c7b3cde1
commit f9a461a6db
2 changed files with 6 additions and 1 deletions

View File

@ -1,4 +1,5 @@
use crate::{ use crate::{
Session,
lint::DiagnosticsMap, lint::DiagnosticsMap,
session::{Client, DocumentQuery, DocumentSnapshot}, session::{Client, DocumentQuery, DocumentSnapshot},
}; };
@ -38,9 +39,13 @@ pub(super) fn publish_diagnostics_for_document(
} }
pub(super) fn clear_diagnostics_for_document( pub(super) fn clear_diagnostics_for_document(
session: &Session,
query: &DocumentQuery, query: &DocumentQuery,
client: &Client, client: &Client,
) -> crate::server::Result<()> { ) -> crate::server::Result<()> {
if session.resolved_client_capabilities().pull_diagnostics {
return Ok(());
}
client client
.send_notification::<lsp_types::notification::PublishDiagnostics>( .send_notification::<lsp_types::notification::PublishDiagnostics>(
lsp_types::PublishDiagnosticsParams { lsp_types::PublishDiagnosticsParams {

View File

@ -27,7 +27,7 @@ impl super::SyncNotificationHandler for DidClose {
); );
return Ok(()); return Ok(());
}; };
clear_diagnostics_for_document(snapshot.query(), client)?; clear_diagnostics_for_document(session, snapshot.query(), client)?;
session session
.close_document(&key) .close_document(&key)