aboutsummaryrefslogtreecommitdiff
path: root/helix-view/src
diff options
context:
space:
mode:
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