mirror of https://github.com/astral-sh/ruff
[`ty`] Add capabilities check for `clear_diagnostics` (#20989)
This commit is contained in:
parent
a7c38eb122
commit
1197035c02
|
|
@ -120,7 +120,11 @@ impl LspDiagnostics {
|
||||||
/// This is done by notifying the client with an empty list of diagnostics for the document.
|
/// 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 notebook cells, this clears diagnostics for the specific cell.
|
||||||
/// For other document types, this clears diagnostics for the main document.
|
/// 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 {
|
let Some(uri) = key.to_url() else {
|
||||||
// If we can't convert to URL, we can't clear diagnostics
|
// If we can't convert to URL, we can't clear diagnostics
|
||||||
return;
|
return;
|
||||||
|
|
|
||||||
|
|
@ -65,7 +65,7 @@ impl SyncNotificationHandler for DidCloseTextDocumentHandler {
|
||||||
.diagnostic_mode()
|
.diagnostic_mode()
|
||||||
.is_open_files_only()
|
.is_open_files_only()
|
||||||
{
|
{
|
||||||
clear_diagnostics(&key, client);
|
clear_diagnostics(session, &key, client);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
AnySystemPath::SystemVirtual(virtual_path) => {
|
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
|
// Always clear diagnostics for virtual files, as they don't really exist on disk
|
||||||
// which means closing them is like deleting the file.
|
// which means closing them is like deleting the file.
|
||||||
clear_diagnostics(&key, client);
|
clear_diagnostics(session, &key, client);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue