From 6ea4184fd107e5cc155b95a3cf058200c38d544d Mon Sep 17 00:00:00 2001 From: Aleksey Kladov Date: Tue, 20 Aug 2019 18:53:59 +0300 Subject: translate \n -> \r\n on the way out --- crates/ra_lsp_server/src/main_loop/handlers.rs | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) (limited to 'crates/ra_lsp_server/src/main_loop/handlers.rs') diff --git a/crates/ra_lsp_server/src/main_loop/handlers.rs b/crates/ra_lsp_server/src/main_loop/handlers.rs index b465707f8..3a559e845 100644 --- a/crates/ra_lsp_server/src/main_loop/handlers.rs +++ b/crates/ra_lsp_server/src/main_loop/handlers.rs @@ -138,6 +138,7 @@ pub fn handle_on_type_formatting( let _p = profile("handle_on_type_formatting"); let mut position = params.text_document_position.try_conv_with(&world)?; let line_index = world.analysis().file_line_index(position.file_id)?; + let line_endings = world.file_line_endings(position.file_id); // in `ra_ide_api`, the `on_type` invariant is that // `text.char_at(position) == typed_char`. @@ -156,7 +157,7 @@ pub fn handle_on_type_formatting( // This should be a single-file edit let edit = edit.source_file_edits.pop().unwrap(); - let change: Vec = edit.edit.conv_with(&line_index); + let change: Vec = edit.edit.conv_with((&line_index, line_endings)); Ok(Some(change)) } @@ -370,8 +371,9 @@ pub fn handle_completion( Some(items) => items, }; let line_index = world.analysis().file_line_index(position.file_id)?; + let line_endings = world.file_line_endings(position.file_id); let items: Vec = - items.into_iter().map(|item| item.conv_with(&line_index)).collect(); + items.into_iter().map(|item| item.conv_with((&line_index, line_endings))).collect(); Ok(Some(items.into())) } -- cgit v1.2.3