Skip to content

Commit 63a3c39

Browse files
authored
Merge pull request #18742 from Veykril/push-yswvkzmsvqql
fix: Fix flycheck workspace when requested but package was found
2 parents 7bd85e9 + 6604f22 commit 63a3c39

File tree

1 file changed

+7
-7
lines changed

1 file changed

+7
-7
lines changed

src/tools/rust-analyzer/crates/rust-analyzer/src/handlers/notification.rs

+7-7
Original file line numberDiff line numberDiff line change
@@ -293,7 +293,6 @@ fn run_flycheck(state: &mut GlobalState, vfs_path: VfsPath) -> bool {
293293
let file_id = state.vfs.read().0.file_id(&vfs_path);
294294
if let Some(file_id) = file_id {
295295
let world = state.snapshot();
296-
let source_root_id = world.analysis.source_root_id(file_id).ok();
297296
let may_flycheck_workspace = state.config.flycheck_workspace(None);
298297
let mut updated = false;
299298
let task = move || -> std::result::Result<(), ide::Cancelled> {
@@ -376,16 +375,17 @@ fn run_flycheck(state: &mut GlobalState, vfs_path: VfsPath) -> bool {
376375
let saved_file = vfs_path.as_path().map(|p| p.to_owned());
377376

378377
// Find and trigger corresponding flychecks
379-
for flycheck in world.flycheck.iter() {
378+
'flychecks: for flycheck in world.flycheck.iter() {
380379
for (id, package) in workspace_ids.clone() {
381380
if id == flycheck.id() {
382381
updated = true;
383-
match package.filter(|_| !world.config.flycheck_workspace(source_root_id)) {
384-
Some(package) => flycheck
385-
.restart_for_package(package, target.clone().map(TupleExt::head)),
386-
None => flycheck.restart_workspace(saved_file.clone()),
382+
if may_flycheck_workspace {
383+
flycheck.restart_workspace(saved_file.clone())
384+
} else if let Some(package) = package {
385+
flycheck
386+
.restart_for_package(package, target.clone().map(TupleExt::head))
387387
}
388-
continue;
388+
continue 'flychecks;
389389
}
390390
}
391391
}

0 commit comments

Comments
 (0)