aboutsummaryrefslogtreecommitdiff
path: root/helix-view/src
diff options
context:
space:
mode:
Diffstat (limited to 'helix-view/src')
-rw-r--r--helix-view/src/document.rs24
1 files changed, 14 insertions, 10 deletions
diff --git a/helix-view/src/document.rs b/helix-view/src/document.rs
index c02d6656..4ad08ce9 100644
--- a/helix-view/src/document.rs
+++ b/helix-view/src/document.rs
@@ -678,17 +678,21 @@ impl Document {
let success = transaction.changes().apply(&mut self.text);
if success {
- // update the selection: either take the selection specified in the transaction, or map the
- // current selection through changes.
- let selection = transaction
- .selection()
- .cloned()
- .unwrap_or_else(|| self.selection(view_id).clone().map(transaction.changes()));
- 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(..));
+ *selection = selection
+ .clone()
+ // Map through changes
+ .map(transaction.changes())
+ // Ensure all selections accross all views still adhere to invariants.
+ .ensure_invariants(self.text.slice(..));
+ }
+
+ // if specified, the current selection should instead be replaced by transaction.selection
+ if let Some(selection) = transaction.selection() {
+ self.selections.insert(
+ view_id,
+ selection.clone().ensure_invariants(self.text.slice(..)),
+ );
}
}