Merge #11151
11151: feat: correctly fallback to notify if the clinet-side file watching is not supported r=matklad a=matklad
bors r+
🤖
Co-authored-by: Aleksey Kladov <aleksey.kladov@gmail.com>
This commit is contained in:
commit
9c210a49b6
@ -723,7 +723,10 @@ impl Config {
|
||||
FilesConfig {
|
||||
watcher: match self.data.files_watcher.as_str() {
|
||||
"notify" => FilesWatcher::Notify,
|
||||
"client" | _ => FilesWatcher::Client,
|
||||
"client" if self.did_change_watched_files_dynamic_registration() => {
|
||||
FilesWatcher::Client
|
||||
}
|
||||
_ => FilesWatcher::Notify,
|
||||
},
|
||||
exclude: self.data.files_excludeDirs.iter().map(|it| self.root_path.join(it)).collect(),
|
||||
}
|
||||
|
@ -241,38 +241,33 @@ impl GlobalState {
|
||||
}
|
||||
|
||||
if let FilesWatcher::Client = self.config.files().watcher {
|
||||
if self.config.did_change_watched_files_dynamic_registration() {
|
||||
let registration_options = lsp_types::DidChangeWatchedFilesRegistrationOptions {
|
||||
watchers: self
|
||||
.workspaces
|
||||
.iter()
|
||||
.flat_map(|ws| ws.to_roots())
|
||||
.filter(|it| it.is_local)
|
||||
.flat_map(|root| {
|
||||
root.include.into_iter().flat_map(|it| {
|
||||
[
|
||||
format!("{}/**/*.rs", it.display()),
|
||||
format!("{}/**/Cargo.toml", it.display()),
|
||||
format!("{}/**/Cargo.lock", it.display()),
|
||||
]
|
||||
})
|
||||
let registration_options = lsp_types::DidChangeWatchedFilesRegistrationOptions {
|
||||
watchers: self
|
||||
.workspaces
|
||||
.iter()
|
||||
.flat_map(|ws| ws.to_roots())
|
||||
.filter(|it| it.is_local)
|
||||
.flat_map(|root| {
|
||||
root.include.into_iter().flat_map(|it| {
|
||||
[
|
||||
format!("{}/**/*.rs", it.display()),
|
||||
format!("{}/**/Cargo.toml", it.display()),
|
||||
format!("{}/**/Cargo.lock", it.display()),
|
||||
]
|
||||
})
|
||||
.map(|glob_pattern| lsp_types::FileSystemWatcher {
|
||||
glob_pattern,
|
||||
kind: None,
|
||||
})
|
||||
.collect(),
|
||||
};
|
||||
let registration = lsp_types::Registration {
|
||||
id: "workspace/didChangeWatchedFiles".to_string(),
|
||||
method: "workspace/didChangeWatchedFiles".to_string(),
|
||||
register_options: Some(serde_json::to_value(registration_options).unwrap()),
|
||||
};
|
||||
self.send_request::<lsp_types::request::RegisterCapability>(
|
||||
lsp_types::RegistrationParams { registrations: vec![registration] },
|
||||
|_, _| (),
|
||||
);
|
||||
}
|
||||
})
|
||||
.map(|glob_pattern| lsp_types::FileSystemWatcher { glob_pattern, kind: None })
|
||||
.collect(),
|
||||
};
|
||||
let registration = lsp_types::Registration {
|
||||
id: "workspace/didChangeWatchedFiles".to_string(),
|
||||
method: "workspace/didChangeWatchedFiles".to_string(),
|
||||
register_options: Some(serde_json::to_value(registration_options).unwrap()),
|
||||
};
|
||||
self.send_request::<lsp_types::request::RegisterCapability>(
|
||||
lsp_types::RegistrationParams { registrations: vec![registration] },
|
||||
|_, _| (),
|
||||
);
|
||||
}
|
||||
|
||||
let mut change = Change::new();
|
||||
|
@ -101,6 +101,14 @@ impl<'a> Project<'a> {
|
||||
let mut config = Config::new(
|
||||
tmp_dir_path,
|
||||
lsp_types::ClientCapabilities {
|
||||
workspace: Some(lsp_types::WorkspaceClientCapabilities {
|
||||
did_change_watched_files: Some(
|
||||
lsp_types::DidChangeWatchedFilesClientCapabilities {
|
||||
dynamic_registration: Some(true),
|
||||
},
|
||||
),
|
||||
..Default::default()
|
||||
}),
|
||||
text_document: Some(lsp_types::TextDocumentClientCapabilities {
|
||||
definition: Some(lsp_types::GotoCapability {
|
||||
link_support: Some(true),
|
||||
|
@ -52,7 +52,9 @@ impl Drop for TestDir {
|
||||
if self.keep {
|
||||
return;
|
||||
}
|
||||
remove_dir_all(&self.path).unwrap()
|
||||
remove_dir_all(&self.path).unwrap_or_else(|err| {
|
||||
panic!("failed to remove temporary directory {}: {}", self.path.display(), err)
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user