aboutsummaryrefslogtreecommitdiff
path: root/helix-view/src/document.rs
diff options
context:
space:
mode:
authorMichael Davis2022-11-27 16:46:42 +0000
committerBlaž Hrastnik2022-11-29 16:15:20 +0000
commit4d1f5389f99013be99b9498fd3fee78eec6217f3 (patch)
tree179f1d5835243f78567c32a221ea13634f692aa5 /helix-view/src/document.rs
parentdf5457a6e71b58a39e198642efd7be0c4963153d (diff)
Revert "Don't apply transactions to Views in undo/redo"
This reverts commit fd00f3a70eb626242bb2fcc9bddf2c4d94580a9a.
Diffstat (limited to 'helix-view/src/document.rs')
-rw-r--r--helix-view/src/document.rs24
1 files changed, 12 insertions, 12 deletions
diff --git a/helix-view/src/document.rs b/helix-view/src/document.rs
index 0eb54f25..08708528 100644
--- a/helix-view/src/document.rs
+++ b/helix-view/src/document.rs
@@ -857,11 +857,11 @@ impl Document {
success
}
- fn undo_redo_impl(&mut self, view_id: ViewId, undo: bool) -> bool {
+ fn undo_redo_impl(&mut self, view: &mut View, undo: bool) -> bool {
let mut history = self.history.take();
let txn = if undo { history.undo() } else { history.redo() };
let success = if let Some(txn) = txn {
- self.apply_impl(txn, view_id)
+ self.apply_impl(txn, view.id) && view.apply(txn, self)
} else {
false
};
@@ -875,13 +875,13 @@ impl Document {
}
/// Undo the last modification to the [`Document`]. Returns whether the undo was successful.
- pub fn undo(&mut self, view_id: ViewId) -> bool {
- self.undo_redo_impl(view_id, true)
+ pub fn undo(&mut self, view: &mut View) -> bool {
+ self.undo_redo_impl(view, true)
}
/// Redo the last modification to the [`Document`]. Returns whether the redo was successful.
- pub fn redo(&mut self, view_id: ViewId) -> bool {
- self.undo_redo_impl(view_id, false)
+ pub fn redo(&mut self, view: &mut View) -> bool {
+ self.undo_redo_impl(view, false)
}
pub fn savepoint(&mut self) {
@@ -894,7 +894,7 @@ impl Document {
}
}
- fn earlier_later_impl(&mut self, view_id: ViewId, uk: UndoKind, earlier: bool) -> bool {
+ fn earlier_later_impl(&mut self, view: &mut View, uk: UndoKind, earlier: bool) -> bool {
let txns = if earlier {
self.history.get_mut().earlier(uk)
} else {
@@ -902,7 +902,7 @@ impl Document {
};
let mut success = false;
for txn in txns {
- if self.apply_impl(&txn, view_id) {
+ if self.apply_impl(&txn, view.id) && view.apply(&txn, self) {
success = true;
}
}
@@ -914,13 +914,13 @@ impl Document {
}
/// Undo modifications to the [`Document`] according to `uk`.
- pub fn earlier(&mut self, view_id: ViewId, uk: UndoKind) -> bool {
- self.earlier_later_impl(view_id, uk, true)
+ pub fn earlier(&mut self, view: &mut View, uk: UndoKind) -> bool {
+ self.earlier_later_impl(view, uk, true)
}
/// Redo modifications to the [`Document`] according to `uk`.
- pub fn later(&mut self, view_id: ViewId, uk: UndoKind) -> bool {
- self.earlier_later_impl(view_id, uk, false)
+ pub fn later(&mut self, view: &mut View, uk: UndoKind) -> bool {
+ self.earlier_later_impl(view, uk, false)
}
/// Commit pending changes to history