diff options
author | Ville Penttinen <[email protected]> | 2019-03-25 07:03:10 +0000 |
---|---|---|
committer | Ville Penttinen <[email protected]> | 2019-03-25 07:03:10 +0000 |
commit | b92fcbc9567674cd240cc533aa021f63019ec38d (patch) | |
tree | 4eb3b02be2a092284c3a6cee93db07df16ee12f7 /crates/ra_ide_api/src/typing.rs | |
parent | 22e1c7a112832a18509d400841b3d162228372bf (diff) |
Further improvements to the SourceChange convenience methods
Rename system_edit to file_system_edit, add more documentation, add
source_file_edit_from to create a SourceChange from `FileId` and `TextEdit`.
Diffstat (limited to 'crates/ra_ide_api/src/typing.rs')
-rw-r--r-- | crates/ra_ide_api/src/typing.rs | 12 |
1 files changed, 5 insertions, 7 deletions
diff --git a/crates/ra_ide_api/src/typing.rs b/crates/ra_ide_api/src/typing.rs index 424084468..aa9971450 100644 --- a/crates/ra_ide_api/src/typing.rs +++ b/crates/ra_ide_api/src/typing.rs | |||
@@ -112,16 +112,14 @@ pub(crate) fn on_dot_typed(db: &RootDatabase, position: FilePosition) -> Option< | |||
112 | TextRange::from_to(position.offset - current_indent_len, position.offset), | 112 | TextRange::from_to(position.offset - current_indent_len, position.offset), |
113 | target_indent.into(), | 113 | target_indent.into(), |
114 | ); | 114 | ); |
115 | let res = SourceChange { | 115 | |
116 | label: "reindent dot".to_string(), | 116 | let res = SourceChange::source_file_edit_from("reindent dot", position.file_id, edit.finish()) |
117 | source_file_edits: vec![SourceFileEdit { edit: edit.finish(), file_id: position.file_id }], | 117 | .with_cursor(FilePosition { |
118 | file_system_edits: vec![], | ||
119 | cursor_position: Some(FilePosition { | ||
120 | offset: position.offset + target_indent_len - current_indent_len | 118 | offset: position.offset + target_indent_len - current_indent_len |
121 | + TextUnit::of_char('.'), | 119 | + TextUnit::of_char('.'), |
122 | file_id: position.file_id, | 120 | file_id: position.file_id, |
123 | }), | 121 | }); |
124 | }; | 122 | |
125 | Some(res) | 123 | Some(res) |
126 | } | 124 | } |
127 | 125 | ||