aboutsummaryrefslogtreecommitdiff
path: root/crates/ra_lsp_server/src/main_loop
diff options
context:
space:
mode:
authorVincent RouillĂ© <[email protected]>2019-12-04 22:05:01 +0000
committerVincent RouillĂ© <[email protected]>2019-12-04 22:05:01 +0000
commitb437dca4bd100c0a7a498d5960d566a0ccd92432 (patch)
treef714271189e0267324265830e4c3dc513b81cb11 /crates/ra_lsp_server/src/main_loop
parent1fe0b8c03fa613262afd2d612c55cc3a11249c7e (diff)
Run rustfmt with respect to Cargo.toml edition
Diffstat (limited to 'crates/ra_lsp_server/src/main_loop')
-rw-r--r--crates/ra_lsp_server/src/main_loop/handlers.rs6
1 files changed, 6 insertions, 0 deletions
diff --git a/crates/ra_lsp_server/src/main_loop/handlers.rs b/crates/ra_lsp_server/src/main_loop/handlers.rs
index ca47ff5e1..409583634 100644
--- a/crates/ra_lsp_server/src/main_loop/handlers.rs
+++ b/crates/ra_lsp_server/src/main_loop/handlers.rs
@@ -555,12 +555,18 @@ pub fn handle_formatting(
555 let _p = profile("handle_formatting"); 555 let _p = profile("handle_formatting");
556 let file_id = params.text_document.try_conv_with(&world)?; 556 let file_id = params.text_document.try_conv_with(&world)?;
557 let file = world.analysis().file_text(file_id)?; 557 let file = world.analysis().file_text(file_id)?;
558 let crate_ids = world.analysis().crate_for(file_id)?;
558 559
559 let file_line_index = world.analysis().file_line_index(file_id)?; 560 let file_line_index = world.analysis().file_line_index(file_id)?;
560 let end_position = TextUnit::of_str(&file).conv_with(&file_line_index); 561 let end_position = TextUnit::of_str(&file).conv_with(&file_line_index);
561 562
562 use std::process; 563 use std::process;
563 let mut rustfmt = process::Command::new("rustfmt"); 564 let mut rustfmt = process::Command::new("rustfmt");
565 if let Some(&crate_id) = crate_ids.first() {
566 // Assume all crates are in the same edition
567 let edition = world.analysis().crate_edition(crate_id)?;
568 rustfmt.args(&["--edition", &edition.to_string()]);
569 }
564 rustfmt.stdin(process::Stdio::piped()).stdout(process::Stdio::piped()); 570 rustfmt.stdin(process::Stdio::piped()).stdout(process::Stdio::piped());
565 571
566 if let Ok(path) = params.text_document.uri.to_file_path() { 572 if let Ok(path) = params.text_document.uri.to_file_path() {