aboutsummaryrefslogtreecommitdiff
path: root/crates/rust-analyzer/src/reload.rs
diff options
context:
space:
mode:
authorJonas Schievink <[email protected]>2020-09-17 17:50:30 +0100
committerJonas Schievink <[email protected]>2020-09-27 18:41:54 +0100
commit1a28f30ba48254fae30a29c2f1053f653d5e687e (patch)
tree66fb358443e69ad81bd9a5331b205891a7d5acfc /crates/rust-analyzer/src/reload.rs
parent662ed41ebcb1cd221b32be95d08b5bf5f10ae525 (diff)
Spawn a flycheck instance per workspace
Diffstat (limited to 'crates/rust-analyzer/src/reload.rs')
-rw-r--r--crates/rust-analyzer/src/reload.rs22
1 files changed, 15 insertions, 7 deletions
diff --git a/crates/rust-analyzer/src/reload.rs b/crates/rust-analyzer/src/reload.rs
index b070087a4..de0dbcad4 100644
--- a/crates/rust-analyzer/src/reload.rs
+++ b/crates/rust-analyzer/src/reload.rs
@@ -235,29 +235,37 @@ impl GlobalState {
235 let config = match self.config.flycheck.clone() { 235 let config = match self.config.flycheck.clone() {
236 Some(it) => it, 236 Some(it) => it,
237 None => { 237 None => {
238 self.flycheck = None; 238 self.flycheck = Vec::new();
239 return; 239 return;
240 } 240 }
241 }; 241 };
242 242
243 let sender = self.flycheck_sender.clone(); 243 let sender = self.flycheck_sender.clone();
244 let sender = Box::new(move |msg| sender.send(msg).unwrap());
245 self.flycheck = self 244 self.flycheck = self
246 .workspaces 245 .workspaces
247 .iter() 246 .iter()
248 // FIXME: Figure out the multi-workspace situation 247 .enumerate()
249 .find_map(|w| match w { 248 .filter_map(|(id, w)| match w {
250 ProjectWorkspace::Cargo { cargo, sysroot: _ } => Some(cargo.workspace_root()), 249 ProjectWorkspace::Cargo { cargo, sysroot: _ } => Some((id, cargo.workspace_root())),
251 ProjectWorkspace::Json { project, .. } => { 250 ProjectWorkspace::Json { project, .. } => {
252 // Enable flychecks for json projects if a custom flycheck command was supplied 251 // Enable flychecks for json projects if a custom flycheck command was supplied
253 // in the workspace configuration. 252 // in the workspace configuration.
254 match config { 253 match config {
255 FlycheckConfig::CustomCommand { .. } => Some(project.path()), 254 FlycheckConfig::CustomCommand { .. } => Some((id, project.path())),
256 _ => None, 255 _ => None,
257 } 256 }
258 } 257 }
259 }) 258 })
260 .map(move |root| FlycheckHandle::spawn(sender, config, root.to_path_buf().into())) 259 .map(|(id, root)| {
260 let sender = sender.clone();
261 FlycheckHandle::spawn(
262 id,
263 Box::new(move |msg| sender.send(msg).unwrap()),
264 config.clone(),
265 root.to_path_buf().into(),
266 )
267 })
268 .collect();
261 } 269 }
262} 270}
263 271