aboutsummaryrefslogtreecommitdiff
path: root/helix-core/src/transaction.rs
diff options
context:
space:
mode:
authorBlaž Hrastnik2020-05-28 05:59:50 +0000
committerBlaž Hrastnik2020-05-28 05:59:50 +0000
commit1984410ac998ac5561f4a3de87d3d125f2f61178 (patch)
treea9a267d6db8763733da5bf468cad870be3acb650 /helix-core/src/transaction.rs
parente52e848fd72f2d7fdc9ebe1c8f7bf215d85a02ee (diff)
Selection mapping over changesets.
Diffstat (limited to 'helix-core/src/transaction.rs')
-rw-r--r--helix-core/src/transaction.rs7
1 files changed, 7 insertions, 0 deletions
diff --git a/helix-core/src/transaction.rs b/helix-core/src/transaction.rs
index c6be89ac..8da01c09 100644
--- a/helix-core/src/transaction.rs
+++ b/helix-core/src/transaction.rs
@@ -242,6 +242,13 @@ impl ChangeSet {
}
}
+ /// `true` when the set is empty.
+ #[inline]
+ pub fn is_empty(&self) -> bool {
+ let len = self.changes.len();
+ len == 0 || (len == 1 && self.changes[0] == Change::Retain(self.len))
+ }
+
/// Map a position through the changes.
///
/// `assoc` indicates which size to associate the position with. `Before` will keep the