From 9d5a5211a4ab83fb891c6eb32f6ed6d63b6b027f Mon Sep 17 00:00:00 2001 From: Aleksey Kladov Date: Fri, 31 Jan 2020 13:34:44 +0100 Subject: Small cleanup --- crates/ra_lsp_server/src/main_loop/handlers.rs | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) (limited to 'crates/ra_lsp_server/src') diff --git a/crates/ra_lsp_server/src/main_loop/handlers.rs b/crates/ra_lsp_server/src/main_loop/handlers.rs index 666f2ee29..9aa1e7eea 100644 --- a/crates/ra_lsp_server/src/main_loop/handlers.rs +++ b/crates/ra_lsp_server/src/main_loop/handlers.rs @@ -1,7 +1,11 @@ //! This module is responsible for implementing handlers for Lanuage Server Protocol. //! The majority of requests are fulfilled by calling into the `ra_ide` crate. -use std::{fmt::Write as _, io::Write as _}; +use std::{ + fmt::Write as _, + io::Write as _, + process::{self, Stdio}, +}; use either::Either; use lsp_server::ErrorCode; @@ -582,21 +586,19 @@ pub fn handle_formatting( let file_line_index = world.analysis().file_line_index(file_id)?; let end_position = TextUnit::of_str(&file).conv_with(&file_line_index); - use std::process; let mut rustfmt = process::Command::new("rustfmt"); if let Some(&crate_id) = crate_ids.first() { // Assume all crates are in the same edition let edition = world.analysis().crate_edition(crate_id)?; rustfmt.args(&["--edition", &edition.to_string()]); } - rustfmt.stdin(process::Stdio::piped()).stdout(process::Stdio::piped()); 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.spawn()?; + let mut rustfmt = rustfmt.stdin(Stdio::piped()).stdout(Stdio::piped()).spawn()?; rustfmt.stdin.as_mut().unwrap().write_all(file.as_bytes())?; -- cgit v1.2.3