Unnamed repository; edit this file 'description' to name the repository.
Merge pull request #22010 from erfanio/rustfmt-fix
Fix rustfmt relative custom command
Lukas Wirth 6 weeks ago
parent 9eb97ea · parent 342d9ed · commit 55825a4
-rw-r--r--crates/rust-analyzer/src/handlers/request.rs3
1 files changed, 1 insertions, 2 deletions
diff --git a/crates/rust-analyzer/src/handlers/request.rs b/crates/rust-analyzer/src/handlers/request.rs
index 86516b6079..c1806c82c7 100644
--- a/crates/rust-analyzer/src/handlers/request.rs
+++ b/crates/rust-analyzer/src/handlers/request.rs
@@ -2442,8 +2442,7 @@ fn run_rustfmt(
}
RustfmtConfig::CustomCommand { command, args } => {
let cmd = Utf8PathBuf::from(&command);
- let target_spec =
- crates.first().and_then(|&crate_id| snap.target_spec_for_file(file_id, crate_id));
+ let target_spec = TargetSpec::for_file(snap, file_id).ok().flatten();
let extra_env = snap.config.extra_env(source_root_id);
let mut cmd = match target_spec {
Some(TargetSpec::Cargo(_)) => {