aboutsummaryrefslogtreecommitdiff
path: root/helix-lsp/src/lib.rs
diff options
context:
space:
mode:
Diffstat (limited to 'helix-lsp/src/lib.rs')
-rw-r--r--helix-lsp/src/lib.rs9
1 files changed, 8 insertions, 1 deletions
diff --git a/helix-lsp/src/lib.rs b/helix-lsp/src/lib.rs
index a51a11fc..93bc06b5 100644
--- a/helix-lsp/src/lib.rs
+++ b/helix-lsp/src/lib.rs
@@ -28,7 +28,7 @@ pub enum Error {
pub mod util {
use super::*;
- use helix_core::{RopeSlice, State, Transaction};
+ use helix_core::{Range, RopeSlice, State, Transaction};
pub fn lsp_pos_to_pos(doc: RopeSlice, pos: lsp::Position) -> usize {
let line = doc.line_to_char(pos.line as usize);
@@ -43,6 +43,13 @@ pub mod util {
lsp::Position::new(line as u32, col as u32)
}
+ pub fn range_to_lsp_range(doc: RopeSlice, range: Range) -> lsp::Range {
+ let start = pos_to_lsp_pos(doc, range.from());
+ let end = pos_to_lsp_pos(doc, range.to());
+
+ lsp::Range::new(start, end)
+ }
+
pub fn generate_transaction_from_edits(
state: &State,
edits: Vec<lsp::TextEdit>,