diff --git a/helix-core/src/history.rs b/helix-core/src/history.rs index 8a8702b9cc6aa..c61515db0ea1d 100644 --- a/helix-core/src/history.rs +++ b/helix-core/src/history.rs @@ -126,15 +126,9 @@ impl History { return None; } - let mut transaction = self.revisions[revision].transaction.clone(); - // The bounds are checked in the if condition above: // `revision + 1` is known to be `<= self.current`. - for revision in &self.revisions[revision + 1..self.current] { - transaction = transaction.compose(revision.transaction.clone()); - } - - Some(transaction) + self.revisions[revision..self.current].iter().cloned().reduce(|acc, transaction| acc.compose(transaction)) } /// Undo the last edit.