mirror of
https://github.com/rust-lang/rust-analyzer.git
synced 2025-10-01 14:21:44 +00:00
Add SnippetEdit
to be alongside source changes
Rendering of snippet edits is deferred to places using source change
This commit is contained in:
parent
75ac37f317
commit
89f7bf7411
7 changed files with 335 additions and 160 deletions
|
@ -353,7 +353,8 @@ pub(crate) fn handle_on_type_formatting(
|
|||
};
|
||||
|
||||
// This should be a single-file edit
|
||||
let (_, text_edit) = edit.source_file_edits.into_iter().next().unwrap();
|
||||
let (_, (text_edit, snippet_edit)) = edit.source_file_edits.into_iter().next().unwrap();
|
||||
stdx::never!(snippet_edit.is_none(), "on type formatting shouldn't use structured snippets");
|
||||
|
||||
let change = to_proto::snippet_text_edit_vec(&line_index, edit.is_snippet, text_edit);
|
||||
Ok(Some(change))
|
||||
|
|
|
@ -973,7 +973,7 @@ pub(crate) fn snippet_workspace_edit(
|
|||
let ops = snippet_text_document_ops(snap, op)?;
|
||||
document_changes.extend_from_slice(&ops);
|
||||
}
|
||||
for (file_id, edit) in source_change.source_file_edits {
|
||||
for (file_id, (edit, _snippet_edit)) in source_change.source_file_edits {
|
||||
let edit = snippet_text_document_edit(snap, source_change.is_snippet, file_id, edit)?;
|
||||
document_changes.push(lsp_ext::SnippetDocumentChangeOperation::Edit(edit));
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue