diff options
author | bors[bot] <26634292+bors[bot]@users.noreply.github.com> | 2019-10-26 18:11:58 +0100 |
---|---|---|
committer | GitHub <[email protected]> | 2019-10-26 18:11:58 +0100 |
commit | 733fd64260793a0f7335e4f75ba9197d5fa98b70 (patch) | |
tree | 644d492ac7bc4a08cd7938be0218dbf8f88b598b /crates/ra_ide_api/src/typing.rs | |
parent | 568ef921acb8d35eed434089c1b1947c585c3f4c (diff) | |
parent | 431e4ff4ef83455adc7e2c0e3f732d6dc482641e (diff) |
Merge #2079
2079: avoid TextEditorBuilder for simple edits r=matklad a=matklad
Co-authored-by: Aleksey Kladov <[email protected]>
Diffstat (limited to 'crates/ra_ide_api/src/typing.rs')
-rw-r--r-- | crates/ra_ide_api/src/typing.rs | 7 |
1 files changed, 3 insertions, 4 deletions
diff --git a/crates/ra_ide_api/src/typing.rs b/crates/ra_ide_api/src/typing.rs index 26a3111fd..2dfbe6944 100644 --- a/crates/ra_ide_api/src/typing.rs +++ b/crates/ra_ide_api/src/typing.rs | |||
@@ -22,7 +22,7 @@ use ra_syntax::{ | |||
22 | SyntaxKind::*, | 22 | SyntaxKind::*, |
23 | SyntaxToken, TextRange, TextUnit, TokenAtOffset, | 23 | SyntaxToken, TextRange, TextUnit, TokenAtOffset, |
24 | }; | 24 | }; |
25 | use ra_text_edit::{TextEdit, TextEditBuilder}; | 25 | use ra_text_edit::TextEdit; |
26 | 26 | ||
27 | use crate::{db::RootDatabase, source_change::SingleFileChange, SourceChange, SourceFileEdit}; | 27 | use crate::{db::RootDatabase, source_change::SingleFileChange, SourceChange, SourceFileEdit}; |
28 | 28 | ||
@@ -49,13 +49,12 @@ pub(crate) fn on_enter(db: &RootDatabase, position: FilePosition) -> Option<Sour | |||
49 | let indent = node_indent(&file, comment.syntax())?; | 49 | let indent = node_indent(&file, comment.syntax())?; |
50 | let inserted = format!("\n{}{} ", indent, prefix); | 50 | let inserted = format!("\n{}{} ", indent, prefix); |
51 | let cursor_position = position.offset + TextUnit::of_str(&inserted); | 51 | let cursor_position = position.offset + TextUnit::of_str(&inserted); |
52 | let mut edit = TextEditBuilder::default(); | 52 | let edit = TextEdit::insert(position.offset, inserted); |
53 | edit.insert(position.offset, inserted); | ||
54 | 53 | ||
55 | Some( | 54 | Some( |
56 | SourceChange::source_file_edit( | 55 | SourceChange::source_file_edit( |
57 | "on enter", | 56 | "on enter", |
58 | SourceFileEdit { edit: edit.finish(), file_id: position.file_id }, | 57 | SourceFileEdit { edit, file_id: position.file_id }, |
59 | ) | 58 | ) |
60 | .with_cursor(FilePosition { offset: cursor_position, file_id: position.file_id }), | 59 | .with_cursor(FilePosition { offset: cursor_position, file_id: position.file_id }), |
61 | ) | 60 | ) |