mirror of
https://github.com/rust-lang/rust-analyzer
synced 2025-01-11 20:58:54 +00:00
Merge pull request #18738 from Veykril/push-vqxqutskzvvu
fix: Properly check if workspace flychecking is allowed
This commit is contained in:
commit
066284addd
5 changed files with 13 additions and 8 deletions
|
@ -644,7 +644,8 @@ config_data! {
|
||||||
/// Aliased as `"checkOnSave.targets"`.
|
/// Aliased as `"checkOnSave.targets"`.
|
||||||
check_targets | checkOnSave_targets | checkOnSave_target: Option<CheckOnSaveTargets> = None,
|
check_targets | checkOnSave_targets | checkOnSave_target: Option<CheckOnSaveTargets> = None,
|
||||||
/// Whether `--workspace` should be passed to `cargo check`.
|
/// Whether `--workspace` should be passed to `cargo check`.
|
||||||
/// If false, `-p <package>` will be passed instead.
|
/// If false, `-p <package>` will be passed instead if applicable. In case it is not, no
|
||||||
|
/// check will be performed.
|
||||||
check_workspace: bool = true,
|
check_workspace: bool = true,
|
||||||
|
|
||||||
/// These proc-macros will be ignored when trying to expand them.
|
/// These proc-macros will be ignored when trying to expand them.
|
||||||
|
|
|
@ -189,7 +189,7 @@ pub(crate) fn handle_did_save_text_document(
|
||||||
if !state.config.check_on_save(Some(sr)) || run_flycheck(state, vfs_path) {
|
if !state.config.check_on_save(Some(sr)) || run_flycheck(state, vfs_path) {
|
||||||
return Ok(());
|
return Ok(());
|
||||||
}
|
}
|
||||||
} else if state.config.check_on_save(None) {
|
} else if state.config.check_on_save(None) && state.config.flycheck_workspace(None) {
|
||||||
// No specific flycheck was triggered, so let's trigger all of them.
|
// No specific flycheck was triggered, so let's trigger all of them.
|
||||||
for flycheck in state.flycheck.iter() {
|
for flycheck in state.flycheck.iter() {
|
||||||
flycheck.restart_workspace(None);
|
flycheck.restart_workspace(None);
|
||||||
|
@ -294,6 +294,7 @@ fn run_flycheck(state: &mut GlobalState, vfs_path: VfsPath) -> bool {
|
||||||
if let Some(file_id) = file_id {
|
if let Some(file_id) = file_id {
|
||||||
let world = state.snapshot();
|
let world = state.snapshot();
|
||||||
let source_root_id = world.analysis.source_root_id(file_id).ok();
|
let source_root_id = world.analysis.source_root_id(file_id).ok();
|
||||||
|
let may_flycheck_workspace = state.config.flycheck_workspace(None);
|
||||||
let mut updated = false;
|
let mut updated = false;
|
||||||
let task = move || -> std::result::Result<(), ide::Cancelled> {
|
let task = move || -> std::result::Result<(), ide::Cancelled> {
|
||||||
// Is the target binary? If so we let flycheck run only for the workspace that contains the crate.
|
// Is the target binary? If so we let flycheck run only for the workspace that contains the crate.
|
||||||
|
@ -389,7 +390,7 @@ fn run_flycheck(state: &mut GlobalState, vfs_path: VfsPath) -> bool {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// No specific flycheck was triggered, so let's trigger all of them.
|
// No specific flycheck was triggered, so let's trigger all of them.
|
||||||
if !updated {
|
if !updated && may_flycheck_workspace {
|
||||||
for flycheck in world.flycheck.iter() {
|
for flycheck in world.flycheck.iter() {
|
||||||
flycheck.restart_workspace(saved_file.clone());
|
flycheck.restart_workspace(saved_file.clone());
|
||||||
}
|
}
|
||||||
|
@ -432,8 +433,10 @@ pub(crate) fn handle_run_flycheck(
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// No specific flycheck was triggered, so let's trigger all of them.
|
// No specific flycheck was triggered, so let's trigger all of them.
|
||||||
for flycheck in state.flycheck.iter() {
|
if state.config.flycheck_workspace(None) {
|
||||||
flycheck.restart_workspace(None);
|
for flycheck in state.flycheck.iter() {
|
||||||
|
flycheck.restart_workspace(None);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
|
@ -408,7 +408,7 @@ impl GlobalState {
|
||||||
if self.is_quiescent() {
|
if self.is_quiescent() {
|
||||||
let became_quiescent = !was_quiescent;
|
let became_quiescent = !was_quiescent;
|
||||||
if became_quiescent {
|
if became_quiescent {
|
||||||
if self.config.check_on_save(None) {
|
if self.config.check_on_save(None) && self.config.flycheck_workspace(None) {
|
||||||
// Project has loaded properly, kick off initial flycheck
|
// Project has loaded properly, kick off initial flycheck
|
||||||
self.flycheck.iter().for_each(|flycheck| flycheck.restart_workspace(None));
|
self.flycheck.iter().for_each(|flycheck| flycheck.restart_workspace(None));
|
||||||
}
|
}
|
||||||
|
|
|
@ -270,7 +270,8 @@ Aliased as `"checkOnSave.targets"`.
|
||||||
+
|
+
|
||||||
--
|
--
|
||||||
Whether `--workspace` should be passed to `cargo check`.
|
Whether `--workspace` should be passed to `cargo check`.
|
||||||
If false, `-p <package>` will be passed instead.
|
If false, `-p <package>` will be passed instead if applicable. In case it is not, no
|
||||||
|
check will be performed.
|
||||||
--
|
--
|
||||||
[[rust-analyzer.completion.addSemicolonToUnit]]rust-analyzer.completion.addSemicolonToUnit (default: `true`)::
|
[[rust-analyzer.completion.addSemicolonToUnit]]rust-analyzer.completion.addSemicolonToUnit (default: `true`)::
|
||||||
+
|
+
|
||||||
|
|
|
@ -1098,7 +1098,7 @@
|
||||||
"title": "check",
|
"title": "check",
|
||||||
"properties": {
|
"properties": {
|
||||||
"rust-analyzer.check.workspace": {
|
"rust-analyzer.check.workspace": {
|
||||||
"markdownDescription": "Whether `--workspace` should be passed to `cargo check`.\nIf false, `-p <package>` will be passed instead.",
|
"markdownDescription": "Whether `--workspace` should be passed to `cargo check`.\nIf false, `-p <package>` will be passed instead if applicable. In case it is not, no\ncheck will be performed.",
|
||||||
"default": true,
|
"default": true,
|
||||||
"type": "boolean"
|
"type": "boolean"
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue