diff options
author | Blaž Hrastnik | 2021-03-18 04:45:57 +0000 |
---|---|---|
committer | Blaž Hrastnik | 2021-03-18 05:17:32 +0000 |
commit | 59e60241864dcf711325109423d74cf6e8b6463d (patch) | |
tree | d89a4036a46d2533321c1dd62b1d3c3b60fda693 /helix-lsp/src | |
parent | dbcc099f484ad186782370ed0cf61b3e8d27282b (diff) |
Remove State from a few more signatures.
Diffstat (limited to 'helix-lsp/src')
-rw-r--r-- | helix-lsp/src/lib.rs | 15 |
1 files changed, 6 insertions, 9 deletions
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<lsp::TextEdit>, - ) -> Transaction { - let doc = state.doc.slice(..); + pub fn generate_transaction_from_edits(doc: &Rope, edits: Vec<lsp::TextEdit>) -> 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) }), ) |