diff options
author | Bernardo <[email protected]> | 2018-12-25 19:49:18 +0000 |
---|---|---|
committer | Bernardo <[email protected]> | 2018-12-25 19:49:18 +0000 |
commit | e9c186e48a77b536053c0f75ac9ea5b2fd322cfa (patch) | |
tree | 250b7f1c4b29e1ca009f6ff913733401caefdb2c /crates/ra_lsp_server/src | |
parent | 863ed19946d6f707ce09dd77bf26b26be73e097c (diff) |
change to `TextEdit` to avoid allocation and sort
rename newline to step where applicable
Diffstat (limited to 'crates/ra_lsp_server/src')
-rw-r--r-- | crates/ra_lsp_server/src/conv.rs | 10 |
1 files changed, 6 insertions, 4 deletions
diff --git a/crates/ra_lsp_server/src/conv.rs b/crates/ra_lsp_server/src/conv.rs index 63827aeea..5a911d9d2 100644 --- a/crates/ra_lsp_server/src/conv.rs +++ b/crates/ra_lsp_server/src/conv.rs | |||
@@ -235,13 +235,15 @@ impl TryConvWith for SourceChange { | |||
235 | None => None, | 235 | None => None, |
236 | Some(pos) => { | 236 | Some(pos) => { |
237 | let line_index = world.analysis().file_line_index(pos.file_id); | 237 | let line_index = world.analysis().file_line_index(pos.file_id); |
238 | let edits = self | 238 | let edit = self |
239 | .source_file_edits | 239 | .source_file_edits |
240 | .iter() | 240 | .iter() |
241 | .find(|it| it.file_id == pos.file_id) | 241 | .find(|it| it.file_id == pos.file_id) |
242 | .map(|it| it.edit.as_atoms()) | 242 | .map(|it| &it.edit); |
243 | .unwrap_or(&[]); | 243 | let line_col = match edit { |
244 | let line_col = translate_offset_with_edit(&*line_index, pos.offset, edits); | 244 | Some(edit) => translate_offset_with_edit(&*line_index, pos.offset, edit), |
245 | None => line_index.line_col(pos.offset), | ||
246 | }; | ||
245 | let position = | 247 | let position = |
246 | Position::new(u64::from(line_col.line), u64::from(line_col.col_utf16)); | 248 | Position::new(u64::from(line_col.line), u64::from(line_col.col_utf16)); |
247 | Some(TextDocumentPositionParams { | 249 | Some(TextDocumentPositionParams { |