File tree Expand file tree Collapse file tree 1 file changed +9
-2
lines changed
crates/rust-analyzer/src/handlers Expand file tree Collapse file tree 1 file changed +9
-2
lines changed Original file line number Diff line number Diff line change @@ -2000,8 +2000,15 @@ fn run_rustfmt(
20002000 let workspace = CargoTargetSpec :: for_file ( & snap, file_id) ?;
20012001 let mut cmd = match workspace {
20022002 Some ( spec) => {
2003- let cmd = spec. workspace_root . join ( cmd) ;
2004- process:: Command :: new ( cmd. as_os_str ( ) )
2003+ // approach: if the command name contains a path seperator, join it with the workspace root.
2004+ // however, if the path is absolute, joining will result in the absolute path being preserved.
2005+ // as a fallback, rely on $PATH-based discovery.
2006+ let cmd_path = if command. contains ( std:: path:: MAIN_SEPARATOR_STR ) {
2007+ spec. workspace_root . join ( cmd) . into ( )
2008+ } else {
2009+ cmd
2010+ } ;
2011+ process:: Command :: new ( cmd_path)
20052012 }
20062013 None => process:: Command :: new ( cmd) ,
20072014 } ;
You can’t perform that action at this time.
0 commit comments