aboutsummaryrefslogtreecommitdiff
path: root/helix-view
diff options
context:
space:
mode:
Diffstat (limited to 'helix-view')
-rw-r--r--helix-view/src/document.rs10
1 files changed, 8 insertions, 2 deletions
diff --git a/helix-view/src/document.rs b/helix-view/src/document.rs
index 84de4c43..c2078060 100644
--- a/helix-view/src/document.rs
+++ b/helix-view/src/document.rs
@@ -792,7 +792,8 @@ impl Document {
pub fn set_selection(&mut self, view_id: ViewId, selection: Selection) {
// TODO: use a transaction?
- self.selections.insert(view_id, selection);
+ self.selections
+ .insert(view_id, selection.ensure_invariants(self.text().slice(..)));
}
fn apply_impl(&mut self, transaction: &Transaction, view_id: ViewId) -> bool {
@@ -807,7 +808,12 @@ impl Document {
.selection()
.cloned()
.unwrap_or_else(|| self.selection(view_id).clone().map(transaction.changes()));
- self.set_selection(view_id, selection);
+ self.selections.insert(view_id, selection);
+
+ // Ensure all selections accross all views still adhere to invariants.
+ for selection in self.selections.values_mut() {
+ *selection = selection.clone().ensure_invariants(self.text.slice(..));
+ }
}
if !transaction.changes().is_empty() {