aboutsummaryrefslogtreecommitdiff
path: root/helix-view/src/document.rs
diff options
context:
space:
mode:
authorBlaž Hrastnik2020-10-23 03:06:33 +0000
committerBlaž Hrastnik2020-12-03 04:10:35 +0000
commit55fa86248c77a01900379ec5bca668978fd5c0d3 (patch)
tree3557e8c03412e5cbc9f1992c60540a74d49dd5b0 /helix-view/src/document.rs
parente4070d4de0883c3fc979b3d57b1b43ecb0a0d72f (diff)
Introduce doc.selection()/set_selection()
Diffstat (limited to 'helix-view/src/document.rs')
-rw-r--r--helix-view/src/document.rs11
1 files changed, 11 insertions, 0 deletions
diff --git a/helix-view/src/document.rs b/helix-view/src/document.rs
index 22438926..a313b281 100644
--- a/helix-view/src/document.rs
+++ b/helix-view/src/document.rs
@@ -108,6 +108,11 @@ impl Document {
};
}
+ pub fn set_selection(&mut self, selection: Selection) {
+ // TODO: use a transaction?
+ self.state.selection = selection;
+ }
+
pub fn apply(&mut self, transaction: &Transaction) -> bool {
let old_doc = self.text().clone();
@@ -119,6 +124,8 @@ impl Document {
changes.compose(transaction.changes().clone()).unwrap()
});
+ // TODO: when composing, replace transaction.selection too
+
// update tree-sitter syntax tree
if let Some(syntax) = &mut self.syntax {
// TODO: no unwrap
@@ -150,6 +157,10 @@ impl Document {
&self.state.doc
}
+ pub fn selection(&self) -> &Selection {
+ &self.state.selection
+ }
+
// pub fn slice<R>(&self, range: R) -> RopeSlice where R: RangeBounds {
// self.state.doc.slice
// }