Add SnippetEdit to be alongside source changes

Rendering of snippet edits is deferred to places using source change
This commit is contained in:
DropDemBits 2023-07-12 00:36:06 -04:00
parent 75ac37f317
commit 89f7bf7411
No known key found for this signature in database
GPG key ID: 7FE02A6C1EDFA075
7 changed files with 335 additions and 160 deletions

View file

@ -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))

View file

@ -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));
}