diff options
| author | bors <bors@rust-lang.org> | 2024-10-14 11:37:56 +0000 |
|---|---|---|
| committer | bors <bors@rust-lang.org> | 2024-10-14 11:37:56 +0000 |
| commit | 1ef2712751afa4b243b7c9689fefdeb81df01209 (patch) | |
| tree | 2f9320caf13280a15aa146db8926d8d1967f78ed | |
| parent | 0b99f29198d2bbab28ad8b9dd8944ce9be5e5cfe (diff) | |
| parent | 96d667ba295848ffa55756e15d0b7ad6b7d829fe (diff) | |
| download | rust-1ef2712751afa4b243b7c9689fefdeb81df01209.tar.gz rust-1ef2712751afa4b243b7c9689fefdeb81df01209.zip | |
Auto merge of #18229 - mrkajetanp:rustfmt-path, r=Veykril
fix: Join rustfmt overrideCommand with project root When providing a custom rustfmt command, join it with the project root instead of the workspace root. This fixes rust-analyzer getting the wrong invocation path in projects containing subprojects. This makes the behaviour consistent with how a custom path provided in rust-analyzer.procMacro.server behaves already. Resolves issue #18222
| -rw-r--r-- | src/tools/rust-analyzer/crates/rust-analyzer/src/handlers/request.rs | 6 |
1 files changed, 3 insertions, 3 deletions
diff --git a/src/tools/rust-analyzer/crates/rust-analyzer/src/handlers/request.rs b/src/tools/rust-analyzer/crates/rust-analyzer/src/handlers/request.rs index 9773d8dbce0..3a1770d770d 100644 --- a/src/tools/rust-analyzer/crates/rust-analyzer/src/handlers/request.rs +++ b/src/tools/rust-analyzer/crates/rust-analyzer/src/handlers/request.rs @@ -2201,14 +2201,14 @@ fn run_rustfmt( let cmd = Utf8PathBuf::from(&command); let target_spec = TargetSpec::for_file(snap, file_id)?; let mut cmd = match target_spec { - Some(TargetSpec::Cargo(spec)) => { - // approach: if the command name contains a path separator, join it with the workspace root. + Some(TargetSpec::Cargo(_)) => { + // approach: if the command name contains a path separator, join it with the project root. // however, if the path is absolute, joining will result in the absolute path being preserved. // as a fallback, rely on $PATH-based discovery. let cmd_path = if command.contains(std::path::MAIN_SEPARATOR) || (cfg!(windows) && command.contains('/')) { - spec.workspace_root.join(cmd).into() + snap.config.root_path().join(cmd).into() } else { cmd }; |
