aboutsummaryrefslogtreecommitdiff
path: root/crates/ra_lsp_server/src/main_loop
diff options
context:
space:
mode:
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, 4 insertions, 2 deletions
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(
138 let _p = profile("handle_on_type_formatting"); 138 let _p = profile("handle_on_type_formatting");
139 let mut position = params.text_document_position.try_conv_with(&world)?; 139 let mut position = params.text_document_position.try_conv_with(&world)?;
140 let line_index = world.analysis().file_line_index(position.file_id)?; 140 let line_index = world.analysis().file_line_index(position.file_id)?;
141 let line_endings = world.file_line_endings(position.file_id);
141 142
142 // in `ra_ide_api`, the `on_type` invariant is that 143 // in `ra_ide_api`, the `on_type` invariant is that
143 // `text.char_at(position) == typed_char`. 144 // `text.char_at(position) == typed_char`.
@@ -156,7 +157,7 @@ pub fn handle_on_type_formatting(
156 // This should be a single-file edit 157 // This should be a single-file edit
157 let edit = edit.source_file_edits.pop().unwrap(); 158 let edit = edit.source_file_edits.pop().unwrap();
158 159
159 let change: Vec<TextEdit> = edit.edit.conv_with(&line_index); 160 let change: Vec<TextEdit> = edit.edit.conv_with((&line_index, line_endings));
160 Ok(Some(change)) 161 Ok(Some(change))
161} 162}
162 163
@@ -370,8 +371,9 @@ pub fn handle_completion(
370 Some(items) => items, 371 Some(items) => items,
371 }; 372 };
372 let line_index = world.analysis().file_line_index(position.file_id)?; 373 let line_index = world.analysis().file_line_index(position.file_id)?;
374 let line_endings = world.file_line_endings(position.file_id);
373 let items: Vec<CompletionItem> = 375 let items: Vec<CompletionItem> =
374 items.into_iter().map(|item| item.conv_with(&line_index)).collect(); 376 items.into_iter().map(|item| item.conv_with((&line_index, line_endings))).collect();
375 377
376 Ok(Some(items.into())) 378 Ok(Some(items.into()))
377} 379}