mirror of
https://github.com/astral-sh/ruff.git
synced 2025-11-18 19:41:34 +00:00
[ty] Add capabilities check for clear_diagnostics (#20989)
This commit is contained in:
parent
a7c38eb122
commit
1197035c02
2 changed files with 7 additions and 3 deletions
|
|
@ -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;
|
||||
|
|
|
|||
|
|
@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue