Skip to content

Commit 15a1505

Browse files
committed
Make checkOnSave workspace
1 parent 6485452 commit 15a1505

File tree

3 files changed

+9
-8
lines changed

3 files changed

+9
-8
lines changed

src/tools/rust-analyzer/crates/rust-analyzer/src/config.rs

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -76,8 +76,6 @@ config_data! {
7676
/// How many worker threads to handle priming caches. The default `0` means to pick automatically.
7777
cachePriming_numThreads: NumThreads = NumThreads::Physical,
7878

79-
/// Run the check command for diagnostics on save.
80-
checkOnSave | checkOnSave_enable: bool = true,
8179

8280
/// Check all targets and tests (`--all-targets`). Defaults to
8381
/// `#rust-analyzer.cargo.allTargets#`.
@@ -350,7 +348,7 @@ config_data! {
350348
workspace: struct WorkspaceDefaultConfigData <- WorkspaceConfigInput -> {
351349

352350

353-
/// Pass `--all-targets` to cargo invocation.
351+
/// Pass `--all-targets` to cargo invocation.
354352
cargo_allTargets: bool = true,
355353
/// Automatically refresh project info via `cargo metadata` on
356354
/// `Cargo.toml` or `.cargo/config.toml` changes.
@@ -431,6 +429,9 @@ config_data! {
431429
/// set to a path relative to the workspace to use that path.
432430
cargo_targetDir | rust_analyzerTargetDir: Option<TargetDirectory> = None,
433431

432+
/// Run the check command for diagnostics on save.
433+
checkOnSave | checkOnSave_enable: bool = true,
434+
434435
/// Additional arguments to `rustfmt`.
435436
rustfmt_extraArgs: Vec<String> = vec![],
436437
/// Advanced option, fully override the command rust-analyzer uses for
@@ -1960,8 +1961,8 @@ impl Config {
19601961
})
19611962
}
19621963

1963-
pub fn check_on_save(&self) -> bool {
1964-
*self.checkOnSave()
1964+
pub fn check_on_save(&self, source_root: Option<SourceRootId>) -> bool {
1965+
*self.checkOnSave(source_root)
19651966
}
19661967

19671968
pub fn script_rebuild_on_save(&self, source_root: Option<SourceRootId>) -> bool {

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -189,10 +189,10 @@ pub(crate) fn handle_did_save_text_document(
189189
}
190190
}
191191

192-
if !state.config.check_on_save() || run_flycheck(state, vfs_path) {
192+
if !state.config.check_on_save(Some(sr)) || run_flycheck(state, vfs_path) {
193193
return Ok(());
194194
}
195-
} else if state.config.check_on_save() {
195+
} else if state.config.check_on_save(None) {
196196
// No specific flycheck was triggered, so let's trigger all of them.
197197
for flycheck in state.flycheck.iter() {
198198
flycheck.restart_workspace(None);

src/tools/rust-analyzer/crates/rust-analyzer/src/main_loop.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -404,7 +404,7 @@ impl GlobalState {
404404
if self.is_quiescent() {
405405
let became_quiescent = !was_quiescent;
406406
if became_quiescent {
407-
if self.config.check_on_save() {
407+
if self.config.check_on_save(None) {
408408
// Project has loaded properly, kick off initial flycheck
409409
self.flycheck.iter().for_each(|flycheck| flycheck.restart_workspace(None));
410410
}

0 commit comments

Comments
 (0)