Unnamed repository; edit this file 'description' to name the repository.
Diffstat (limited to 'src/text/hist.rs')
| -rw-r--r-- | src/text/hist.rs | 13 |
1 files changed, 10 insertions, 3 deletions
diff --git a/src/text/hist.rs b/src/text/hist.rs index 97a05c7..05a5bcb 100644 --- a/src/text/hist.rs +++ b/src/text/hist.rs @@ -197,7 +197,7 @@ impl Hist { let c = take(&mut x.changes); self.history.push(Diff(c, [take(&mut self.lc), x.cursor.clone()])); self.lc = x.cursor.clone(); - println!("push {}", self.history.last().unwrap()); + // println!("push {}", self.history.last().unwrap()); self.redo_history.clear(); take(&mut self.last); self.last_edit = Instant::now(); @@ -211,14 +211,21 @@ impl Hist { } pub fn undo(&mut self, t: &mut TextArea) -> ropey::Result<Option<()>> { self.push_if_changed(t); - self.undo_() + let r = self + .undo_() .map(|x| { let r = x.apply(t, false); self.lc = t.cursor.clone(); self.last = t.changes.clone(); r }) - .transpose() + .transpose(); + let l = t.len_chars(); + t.cursor + .inner + .iter_mut() + .for_each(|x| x.position = x.position.min(l)); + r } pub fn redo(&mut self, t: &mut TextArea) -> ropey::Result<Option<()>> { self.redo_() |