diff options
author | Blaž Hrastnik | 2021-03-18 06:23:42 +0000 |
---|---|---|
committer | Blaž Hrastnik | 2021-03-18 06:23:42 +0000 |
commit | e9bd9e72c3adf822ae569644dd87f4a5e04df18e (patch) | |
tree | 9babbf9742c36aacaae3291d2d36e56c5ae9a4a2 /helix-lsp/src | |
parent | 175d38c88cf96dfb6744cb260abf2e8f5c1c48b9 (diff) |
Pos conversions always operate on whole documents.
Diffstat (limited to 'helix-lsp/src')
-rw-r--r-- | helix-lsp/src/client.rs | 1 | ||||
-rw-r--r-- | helix-lsp/src/lib.rs | 13 |
2 files changed, 6 insertions, 8 deletions
diff --git a/helix-lsp/src/client.rs b/helix-lsp/src/client.rs index 97e5cfad..672247a9 100644 --- a/helix-lsp/src/client.rs +++ b/helix-lsp/src/client.rs @@ -297,7 +297,6 @@ impl Client { } let old_text = old_text.slice(..); - let new_text = new_text.slice(..); while let Some(change) = iter.next() { let len = match change { diff --git a/helix-lsp/src/lib.rs b/helix-lsp/src/lib.rs index 936c897c..64aa38f1 100644 --- a/helix-lsp/src/lib.rs +++ b/helix-lsp/src/lib.rs @@ -28,14 +28,14 @@ pub enum Error { pub mod util { use super::*; - use helix_core::{Range, Rope, RopeSlice, Transaction}; + use helix_core::{Range, Rope, Transaction}; - pub fn lsp_pos_to_pos(doc: RopeSlice, pos: lsp::Position) -> usize { + pub fn lsp_pos_to_pos(doc: &Rope, pos: lsp::Position) -> usize { let line = doc.line_to_char(pos.line as usize); let line_start = doc.char_to_utf16_cu(line); doc.utf16_cu_to_char(line_start + pos.character as usize) } - pub fn pos_to_lsp_pos(doc: RopeSlice, pos: usize) -> lsp::Position { + pub fn pos_to_lsp_pos(doc: &Rope, pos: usize) -> lsp::Position { let line = doc.char_to_line(pos); let line_start = doc.char_to_utf16_cu(doc.line_to_char(line)); let col = doc.char_to_utf16_cu(pos) - line_start; @@ -43,7 +43,7 @@ pub mod util { lsp::Position::new(line as u32, col as u32) } - pub fn range_to_lsp_range(doc: RopeSlice, range: Range) -> lsp::Range { + pub fn range_to_lsp_range(doc: &Rope, range: Range) -> lsp::Range { let start = pos_to_lsp_pos(doc, range.from()); let end = pos_to_lsp_pos(doc, range.to()); @@ -51,7 +51,6 @@ pub mod util { } 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( doc, edits.into_iter().map(|edit| { @@ -62,8 +61,8 @@ pub mod util { None }; - let start = lsp_pos_to_pos(text, edit.range.start); - let end = lsp_pos_to_pos(text, edit.range.end); + let start = lsp_pos_to_pos(doc, edit.range.start); + let end = lsp_pos_to_pos(doc, edit.range.end); (start, end, replacement) }), ) |