fix(lsp): respect Dart's own filesystem watcher (#2350)

Цей коміт міститься в:
l0ng-ai authored and GitHub committed 2026-11-09 19:58:10 +08:00
1 джерело b2b881e075
коміт ff2eb95b01
2 files changed
+43

No files matched your search

+4
Переглянути файл
@@ -2584,6 +2584,10 @@ impl LspManager {
let watchers = run.watchers.read();
let roots = self.server_workspace_roots(&s);
let changes: Vec<(&PathBuf, Change)> = if watchers.is_empty() {
// Dart watches the filesystem itself and rejects this unregistered notification.
if s.name == "dart" {
continue;
}
let languages = s.languages();
all.filter(|(p, change)| {
roots.iter().any(|root| p.starts_with(root))
+39
Переглянути файл
@@ -420,6 +420,45 @@ fn change(range: Range, text: &str) -> AppliedChange {
AppliedChange { range, text: text.into() }
}
#[tokio::test(flavor = "multi_thread")]
async fn dart_file_watching_requires_an_explicit_registration() {
for (language, extension, name, fallback) in
[("dart", "dart", "dart", false), ("dart", "dart", "alternative-dart", true), ("java", "java", "jdtls", true)]
{
let h = harness_for(language, extension, &[(name, incremental_caps())], &[]);
let (doc, _) = h.open(&format!("open.{extension}"), "x");
h.wait_status(name, ServerStatus::Ready).await;
let s = h.launcher.state(name);
let path = h.root.join(format!("closed.{extension}"));
let notify = || h.mgr.watched_files_changed(&[], std::slice::from_ref(&path), &[], &[]);
notify();
h.mgr.hover(doc, Pos::new(0, 0), Default::default()).await.unwrap();
assert_eq!(s.notified("workspace/didChangeWatchedFiles").len(), usize::from(fallback), "{name}");
s.peer()
.request::<_, Value>(
"client/registerCapability",
json!({ "registrations": [{ "id": "watch", "method": "workspace/didChangeWatchedFiles", "registerOptions": { "watchers": [{ "globPattern": "**/*" }] } }] }),
None,
)
.await
.unwrap();
notify();
eventually(|| s.notified("workspace/didChangeWatchedFiles").len() == usize::from(fallback) + 1).await;
s.peer()
.request::<_, Value>(
"client/unregisterCapability",
json!({ "unregisterations": [{ "id": "watch", "method": "workspace/didChangeWatchedFiles" }] }),
None,
)
.await
.unwrap();
notify();
h.mgr.hover(doc, Pos::new(0, 0), Default::default()).await.unwrap();
assert_eq!(s.notified("workspace/didChangeWatchedFiles").len(), usize::from(fallback) * 2 + 1, "{name}");
h.mgr.shutdown_all().await;
}
}
// ------------------------------------------------------------------ tests
#[tokio::test(flavor = "multi_thread")]