From 2ca2e24a39594762be80ac11247b231c13a4b2af Mon Sep 17 00:00:00 2001 From: Kirill Bulatov Date: Sun, 23 May 2021 23:10:05 +0300 Subject: Do not add cargo target for detached files only project --- crates/rust-analyzer/src/handlers.rs | 35 ++++++++++++++++++++++------------- 1 file changed, 22 insertions(+), 13 deletions(-) (limited to 'crates') diff --git a/crates/rust-analyzer/src/handlers.rs b/crates/rust-analyzer/src/handlers.rs index aa12fd94b..f48210424 100644 --- a/crates/rust-analyzer/src/handlers.rs +++ b/crates/rust-analyzer/src/handlers.rs @@ -661,19 +661,28 @@ pub(crate) fn handle_runnables( } } None => { - res.push(lsp_ext::Runnable { - label: "cargo check --workspace".to_string(), - location: None, - kind: lsp_ext::RunnableKind::Cargo, - args: lsp_ext::CargoRunnable { - workspace_root: None, - override_cargo: config.override_cargo, - cargo_args: vec!["check".to_string(), "--workspace".to_string()], - cargo_extra_args: config.cargo_extra_args, - executable_args: Vec::new(), - expect_test: None, - }, - }); + if !snap.config.linked_projects().is_empty() + || !snap + .config + .discovered_projects + .as_ref() + .map(|projects| projects.is_empty()) + .unwrap_or(true) + { + res.push(lsp_ext::Runnable { + label: "cargo check --workspace".to_string(), + location: None, + kind: lsp_ext::RunnableKind::Cargo, + args: lsp_ext::CargoRunnable { + workspace_root: None, + override_cargo: config.override_cargo, + cargo_args: vec!["check".to_string(), "--workspace".to_string()], + cargo_extra_args: config.cargo_extra_args, + executable_args: Vec::new(), + expect_test: None, + }, + }); + } } } Ok(res) -- cgit v1.2.3