File tree Expand file tree Collapse file tree 1 file changed +12
-2
lines changed
crates/rust-analyzer/src/handlers Expand file tree Collapse file tree 1 file changed +12
-2
lines changed Original file line number Diff line number Diff line change @@ -2000,8 +2000,18 @@ 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 =
2007+ if cfg ! ( windows) && command. contains ( & [ std:: path:: MAIN_SEPARATOR , '/' ] ) {
2008+ spec. workspace_root . join ( cmd) . into ( )
2009+ } else if command. contains ( std:: path:: MAIN_SEPARATOR ) {
2010+ spec. workspace_root . join ( cmd) . into ( )
2011+ } else {
2012+ cmd
2013+ } ;
2014+ process:: Command :: new ( cmd_path)
20052015 }
20062016 None => process:: Command :: new ( cmd) ,
20072017 } ;
You can’t perform that action at this time.
0 commit comments