Skip to content

Commit 9d5a521

Browse files
committed
Small cleanup
1 parent e48033d commit 9d5a521

File tree

1 file changed

+6
-4
lines changed

1 file changed

+6
-4
lines changed

crates/ra_lsp_server/src/main_loop/handlers.rs

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,11 @@
11
//! This module is responsible for implementing handlers for Lanuage Server Protocol.
22
//! The majority of requests are fulfilled by calling into the `ra_ide` crate.
33
4-
use std::{fmt::Write as _, io::Write as _};
4+
use std::{
5+
fmt::Write as _,
6+
io::Write as _,
7+
process::{self, Stdio},
8+
};
59

610
use either::Either;
711
use lsp_server::ErrorCode;
@@ -582,21 +586,19 @@ pub fn handle_formatting(
582586
let file_line_index = world.analysis().file_line_index(file_id)?;
583587
let end_position = TextUnit::of_str(&file).conv_with(&file_line_index);
584588

585-
use std::process;
586589
let mut rustfmt = process::Command::new("rustfmt");
587590
if let Some(&crate_id) = crate_ids.first() {
588591
// Assume all crates are in the same edition
589592
let edition = world.analysis().crate_edition(crate_id)?;
590593
rustfmt.args(&["--edition", &edition.to_string()]);
591594
}
592-
rustfmt.stdin(process::Stdio::piped()).stdout(process::Stdio::piped());
593595

594596
if let Ok(path) = params.text_document.uri.to_file_path() {
595597
if let Some(parent) = path.parent() {
596598
rustfmt.current_dir(parent);
597599
}
598600
}
599-
let mut rustfmt = rustfmt.spawn()?;
601+
let mut rustfmt = rustfmt.stdin(Stdio::piped()).stdout(Stdio::piped()).spawn()?;
600602

601603
rustfmt.stdin.as_mut().unwrap().write_all(file.as_bytes())?;
602604

0 commit comments

Comments
 (0)