From 59e60241864dcf711325109423d74cf6e8b6463d Mon Sep 17 00:00:00 2001 From: Blaž Hrastnik Date: Thu, 18 Mar 2021 13:45:57 +0900 Subject: Remove State from a few more signatures. --- helix-lsp/src/lib.rs | 15 ++++++--------- 1 file changed, 6 insertions(+), 9 deletions(-) (limited to 'helix-lsp') diff --git a/helix-lsp/src/lib.rs b/helix-lsp/src/lib.rs index 3dcdeb07..29868e82 100644 --- a/helix-lsp/src/lib.rs +++ b/helix-lsp/src/lib.rs @@ -30,7 +30,7 @@ pub enum Error { pub mod util { use super::*; - use helix_core::{Range, RopeSlice, State, Transaction}; + use helix_core::{Range, Rope, RopeSlice, Transaction}; pub fn lsp_pos_to_pos(doc: RopeSlice, pos: lsp::Position) -> usize { let line = doc.line_to_char(pos.line as usize); @@ -52,13 +52,10 @@ pub mod util { lsp::Range::new(start, end) } - pub fn generate_transaction_from_edits( - state: &State, - edits: Vec, - ) -> Transaction { - let doc = state.doc.slice(..); + pub fn generate_transaction_from_edits(doc: &Rope, edits: Vec) -> Transaction { + let text = doc.slice(..); // would be unnecessary if Transaction::change took Rope | RopeSlice Transaction::change( - &state.doc, + doc, edits.into_iter().map(|edit| { // simplify "" into None for cleaner changesets let replacement = if !edit.new_text.is_empty() { @@ -67,8 +64,8 @@ pub mod util { None }; - let start = lsp_pos_to_pos(doc, edit.range.start); - let end = lsp_pos_to_pos(doc, edit.range.end); + let start = lsp_pos_to_pos(text, edit.range.start); + let end = lsp_pos_to_pos(text, edit.range.end); (start, end, replacement) }), ) -- cgit v1.2.3-70-g09d2