5668: Fix relative path handling for custom rustfmt r=matklad a=matklad

`current_dir` and relative paths to executables works differently on
unix and windows (unix behavior does not make sense), see:

17e30e83a1/src/lib.rs (L295-L324)

The original motivation to set cwd was to make rustfmt read the
correct rustfmt.toml, but that was future proofing, rather than a bug
fix.

So, let's just remove this and see if breaks or fixes more use-cases.

If support for per-file config is needed, we could use `--config-path`
flag.



bors r+
🤖

Co-authored-by: Aleksey Kladov <aleksey.kladov@gmail.com>
This commit is contained in:
bors[bot] 2020-08-05 11:26:16 +00:00 committed by GitHub
commit 2ad29eb231
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -709,11 +709,6 @@ pub(crate) fn handle_formatting(
}
};
if let Ok(path) = params.text_document.uri.to_file_path() {
if let Some(parent) = path.parent() {
rustfmt.current_dir(parent);
}
}
let mut rustfmt = rustfmt.stdin(Stdio::piped()).stdout(Stdio::piped()).spawn()?;
rustfmt.stdin.as_mut().unwrap().write_all(file.as_bytes())?;