aboutsummaryrefslogtreecommitdiff
path: root/helix-view/src
diff options
context:
space:
mode:
authorBlaž Hrastnik2022-02-18 05:33:56 +0000
committerBlaž Hrastnik2022-02-18 05:37:59 +0000
commita449156702112a1ee1d11ef2f5495067d801deef (patch)
tree32362b282ea67b3ccbf892293360ed4de768ebf2 /helix-view/src
parent5af9136aec31f712e2dea0f6545edb6fd3bdf4dd (diff)
Extract a lsp position helper
Diffstat (limited to 'helix-view/src')
-rw-r--r--helix-view/src/document.rs14
1 files changed, 14 insertions, 0 deletions
diff --git a/helix-view/src/document.rs b/helix-view/src/document.rs
index c0186ee5..f13338ba 100644
--- a/helix-view/src/document.rs
+++ b/helix-view/src/document.rs
@@ -922,6 +922,20 @@ impl Document {
lsp::VersionedTextDocumentIdentifier::new(self.url().unwrap(), self.version)
}
+ pub fn position(
+ &self,
+ view_id: ViewId,
+ offset_encoding: helix_lsp::OffsetEncoding,
+ ) -> lsp::Position {
+ let text = self.text();
+
+ helix_lsp::util::pos_to_lsp_pos(
+ text,
+ self.selection(view_id).primary().cursor(text.slice(..)),
+ offset_encoding,
+ )
+ }
+
#[inline]
pub fn diagnostics(&self) -> &[Diagnostic] {
&self.diagnostics