File tree Expand file tree Collapse file tree 1 file changed +6
-4
lines changed
crates/ra_lsp_server/src/main_loop Expand file tree Collapse file tree 1 file changed +6
-4
lines changed Original file line number Diff line number Diff line change 1
1
//! This module is responsible for implementing handlers for Lanuage Server Protocol.
2
2
//! The majority of requests are fulfilled by calling into the `ra_ide` crate.
3
3
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
+ } ;
5
9
6
10
use either:: Either ;
7
11
use lsp_server:: ErrorCode ;
@@ -582,21 +586,19 @@ pub fn handle_formatting(
582
586
let file_line_index = world. analysis ( ) . file_line_index ( file_id) ?;
583
587
let end_position = TextUnit :: of_str ( & file) . conv_with ( & file_line_index) ;
584
588
585
- use std:: process;
586
589
let mut rustfmt = process:: Command :: new ( "rustfmt" ) ;
587
590
if let Some ( & crate_id) = crate_ids. first ( ) {
588
591
// Assume all crates are in the same edition
589
592
let edition = world. analysis ( ) . crate_edition ( crate_id) ?;
590
593
rustfmt. args ( & [ "--edition" , & edition. to_string ( ) ] ) ;
591
594
}
592
- rustfmt. stdin ( process:: Stdio :: piped ( ) ) . stdout ( process:: Stdio :: piped ( ) ) ;
593
595
594
596
if let Ok ( path) = params. text_document . uri . to_file_path ( ) {
595
597
if let Some ( parent) = path. parent ( ) {
596
598
rustfmt. current_dir ( parent) ;
597
599
}
598
600
}
599
- let mut rustfmt = rustfmt. spawn ( ) ?;
601
+ let mut rustfmt = rustfmt. stdin ( Stdio :: piped ( ) ) . stdout ( Stdio :: piped ( ) ) . spawn ( ) ?;
600
602
601
603
rustfmt. stdin . as_mut ( ) . unwrap ( ) . write_all ( file. as_bytes ( ) ) ?;
602
604
You can’t perform that action at this time.
0 commit comments