Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions crates/ruff_server/src/server/api/diagnostics.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
use crate::{
Session,
lint::DiagnosticsMap,
session::{Client, DocumentQuery, DocumentSnapshot},
};
Expand Down Expand Up @@ -38,9 +39,13 @@ pub(super) fn publish_diagnostics_for_document(
}

pub(super) fn clear_diagnostics_for_document(
session: &Session,
query: &DocumentQuery,
client: &Client,
) -> crate::server::Result<()> {
if session.resolved_client_capabilities().pull_diagnostics {
return Ok(());
}
Comment on lines +46 to +48
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This change only affects DidClose. For Notebook, there is DidCloseNotebook, so it should not affect Notebook.

impl super::SyncNotificationHandler for DidClose {

impl super::SyncNotificationHandler for DidCloseNotebook {

client
.send_notification::<lsp_types::notification::PublishDiagnostics>(
lsp_types::PublishDiagnosticsParams {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ impl super::SyncNotificationHandler for DidClose {
);
return Ok(());
};
clear_diagnostics_for_document(snapshot.query(), client)?;
clear_diagnostics_for_document(session, snapshot.query(), client)?;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not sure this is correct. This is probably a bit surprising but notebook cells are text documents and the LSP sends close document requests for LSP cells.

Would you mind extending your test plan to cover

  • Closing a notebook that has diagnostics
  • Removing a cell that contains diagnostics


session
.close_document(&key)
Expand Down