Unnamed repository; edit this file 'description' to name the repository.
Make checkOnSave workspace
Ali Bektas 2024-08-29
parent 100d3f9 · commit f099979
-rw-r--r--crates/rust-analyzer/src/config.rs11
-rw-r--r--crates/rust-analyzer/src/handlers/notification.rs4
-rw-r--r--crates/rust-analyzer/src/main_loop.rs2
3 files changed, 9 insertions, 8 deletions
diff --git a/crates/rust-analyzer/src/config.rs b/crates/rust-analyzer/src/config.rs
index 9a8075043e..211e91f7f0 100644
--- a/crates/rust-analyzer/src/config.rs
+++ b/crates/rust-analyzer/src/config.rs
@@ -76,8 +76,6 @@ config_data! {
/// How many worker threads to handle priming caches. The default `0` means to pick automatically.
cachePriming_numThreads: NumThreads = NumThreads::Physical,
- /// Run the check command for diagnostics on save.
- checkOnSave | checkOnSave_enable: bool = true,
/// Check all targets and tests (`--all-targets`). Defaults to
/// `#rust-analyzer.cargo.allTargets#`.
@@ -350,7 +348,7 @@ config_data! {
workspace: struct WorkspaceDefaultConfigData <- WorkspaceConfigInput -> {
-/// Pass `--all-targets` to cargo invocation.
+ /// Pass `--all-targets` to cargo invocation.
cargo_allTargets: bool = true,
/// Automatically refresh project info via `cargo metadata` on
/// `Cargo.toml` or `.cargo/config.toml` changes.
@@ -431,6 +429,9 @@ config_data! {
/// set to a path relative to the workspace to use that path.
cargo_targetDir | rust_analyzerTargetDir: Option<TargetDirectory> = None,
+ /// Run the check command for diagnostics on save.
+ checkOnSave | checkOnSave_enable: bool = true,
+
/// Additional arguments to `rustfmt`.
rustfmt_extraArgs: Vec<String> = vec![],
/// Advanced option, fully override the command rust-analyzer uses for
@@ -1960,8 +1961,8 @@ impl Config {
})
}
- pub fn check_on_save(&self) -> bool {
- *self.checkOnSave()
+ pub fn check_on_save(&self, source_root: Option<SourceRootId>) -> bool {
+ *self.checkOnSave(source_root)
}
pub fn script_rebuild_on_save(&self, source_root: Option<SourceRootId>) -> bool {
diff --git a/crates/rust-analyzer/src/handlers/notification.rs b/crates/rust-analyzer/src/handlers/notification.rs
index 1cbdb50867..336b7ea05a 100644
--- a/crates/rust-analyzer/src/handlers/notification.rs
+++ b/crates/rust-analyzer/src/handlers/notification.rs
@@ -189,10 +189,10 @@ pub(crate) fn handle_did_save_text_document(
}
}
- if !state.config.check_on_save() || run_flycheck(state, vfs_path) {
+ if !state.config.check_on_save(Some(sr)) || run_flycheck(state, vfs_path) {
return Ok(());
}
- } else if state.config.check_on_save() {
+ } else if state.config.check_on_save(None) {
// No specific flycheck was triggered, so let's trigger all of them.
for flycheck in state.flycheck.iter() {
flycheck.restart_workspace(None);
diff --git a/crates/rust-analyzer/src/main_loop.rs b/crates/rust-analyzer/src/main_loop.rs
index 372f060234..a90b988907 100644
--- a/crates/rust-analyzer/src/main_loop.rs
+++ b/crates/rust-analyzer/src/main_loop.rs
@@ -404,7 +404,7 @@ impl GlobalState {
if self.is_quiescent() {
let became_quiescent = !was_quiescent;
if became_quiescent {
- if self.config.check_on_save() {
+ if self.config.check_on_save(None) {
// Project has loaded properly, kick off initial flycheck
self.flycheck.iter().for_each(|flycheck| flycheck.restart_workspace(None));
}