From 5e370b1cb842e2e29a3fc3b8a599cee5b6040a02 Mon Sep 17 00:00:00 2001 From: Wilfred Hughes Date: Wed, 27 Mar 2024 10:33:20 -0700 Subject: [PATCH] Use crate root to choose relevant workspace for flycheck --- crates/project-model/src/project_json.rs | 2 +- crates/rust-analyzer/src/handlers/notification.rs | 7 +++---- 2 files changed, 4 insertions(+), 5 deletions(-) diff --git a/crates/project-model/src/project_json.rs b/crates/project-model/src/project_json.rs index 512588cc8f8f3..54674a6f0f144 100644 --- a/crates/project-model/src/project_json.rs +++ b/crates/project-model/src/project_json.rs @@ -74,7 +74,7 @@ pub struct ProjectJson { #[derive(Clone, Debug, Eq, PartialEq)] pub struct Crate { pub(crate) display_name: Option, - pub(crate) root_module: AbsPathBuf, + pub root_module: AbsPathBuf, pub(crate) edition: Edition, pub(crate) version: Option, pub(crate) deps: Vec, diff --git a/crates/rust-analyzer/src/handlers/notification.rs b/crates/rust-analyzer/src/handlers/notification.rs index b5c4a4f435e73..3b2325781855f 100644 --- a/crates/rust-analyzer/src/handlers/notification.rs +++ b/crates/rust-analyzer/src/handlers/notification.rs @@ -296,10 +296,9 @@ fn run_flycheck(state: &mut GlobalState, vfs_path: VfsPath) -> bool { }) } project_model::ProjectWorkspace::Json { project, .. } => { - if !project - .crates() - .any(|(c, _)| crate_ids.iter().any(|&crate_id| crate_id == c)) - { + if !project.crates().any(|(_, krate)| { + crate_root_paths.contains(&krate.root_module.as_path()) + }) { return None; } None