mirror of
https://github.com/rust-lang/rust-analyzer.git
synced 2025-09-27 20:42:04 +00:00
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`.
This commit is contained in:
parent
22e1c7a112
commit
b92fcbc956
4 changed files with 50 additions and 27 deletions
|
@ -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)
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue