From b92fcbc9567674cd240cc533aa021f63019ec38d Mon Sep 17 00:00:00 2001 From: Ville Penttinen Date: Mon, 25 Mar 2019 09:03:10 +0200 Subject: 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`. --- crates/ra_ide_api/src/typing.rs | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) (limited to 'crates/ra_ide_api/src/typing.rs') 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< TextRange::from_to(position.offset - current_indent_len, position.offset), target_indent.into(), ); - let res = SourceChange { - label: "reindent dot".to_string(), - source_file_edits: vec![SourceFileEdit { edit: edit.finish(), file_id: position.file_id }], - file_system_edits: vec![], - cursor_position: Some(FilePosition { + + let res = SourceChange::source_file_edit_from("reindent dot", position.file_id, edit.finish()) + .with_cursor(FilePosition { offset: position.offset + target_indent_len - current_indent_len + TextUnit::of_char('.'), file_id: position.file_id, - }), - }; + }); + Some(res) } -- cgit v1.2.3