@@ -122,17 +122,21 @@ impl History {
122122 /// Returns the changes since the given revision composed into a transaction.
123123 /// Returns None if there are no changes between the current and given revisions.
124124 pub fn changes_since(&self, revision: usize) -> Option<Transaction> {
125− if self.at_root() || self.current >= revision {
126− return None;
127− }
125+ use std::cmp::Ordering::*;
128126
129− // The bounds are checked in the if condition above:
130− // `revision` is known to be `< self.current`.
131− self.revisions[revision..self.current]
132− .iter()
133− .map(|revision| &revision.transaction)
134− .cloned()
135− .reduce(|acc, transaction| acc.compose(transaction))
127+ match revision.cmp(&self.current) {
128+ Equal => None,
129+ Greater => self.revisions[self.current + 1..=revision]
130+ .iter()
131+ .map(|revision| &revision.inversion)
132+ .cloned()
133+ .reduce(|acc, inversion| acc.compose(inversion)),
134+ Less => self.revisions[revision + 1..=self.current]
135+ .iter()
136+ .map(|revision| &revision.transaction)
137+ .cloned()
138+ .reduce(|acc, transaction| acc.compose(transaction)),
139+ }
136140 }
137141
138142 /// Undo the last edit.