From 7d604584954660d255ad0929d3be8ce03f879d0c Mon Sep 17 00:00:00 2001 From: ivan770 Date: Tue, 16 Mar 2021 14:37:00 +0200 Subject: Item up and down movers --- crates/rust-analyzer/src/to_proto.rs | 12 ++++++++++++ 1 file changed, 12 insertions(+) (limited to 'crates/rust-analyzer/src/to_proto.rs') diff --git a/crates/rust-analyzer/src/to_proto.rs b/crates/rust-analyzer/src/to_proto.rs index 70501618e..3171708d5 100644 --- a/crates/rust-analyzer/src/to_proto.rs +++ b/crates/rust-analyzer/src/to_proto.rs @@ -658,6 +658,18 @@ pub(crate) fn goto_definition_response( } } +pub(crate) fn text_document_edit( + snap: &GlobalStateSnapshot, + file_id: FileId, + edit: TextEdit, +) -> Result { + let text_document = optional_versioned_text_document_identifier(snap, file_id); + let line_index = snap.file_line_index(file_id)?; + let edits = + edit.into_iter().map(|it| lsp_types::OneOf::Left(text_edit(&line_index, it))).collect(); + Ok(lsp_types::TextDocumentEdit { text_document, edits }) +} + pub(crate) fn snippet_text_document_edit( snap: &GlobalStateSnapshot, is_snippet: bool, -- cgit v1.2.3