summaryrefslogtreecommitdiff
path: root/helix-core/src
diff options
context:
space:
mode:
Diffstat (limited to 'helix-core/src')
-rw-r--r--helix-core/src/selection.rs8
-rw-r--r--helix-core/src/transaction.rs5
2 files changed, 7 insertions, 6 deletions
diff --git a/helix-core/src/selection.rs b/helix-core/src/selection.rs
index 87216fd9..9a93e667 100644
--- a/helix-core/src/selection.rs
+++ b/helix-core/src/selection.rs
@@ -278,7 +278,7 @@ pub fn select_on_matches(
text: &RopeSlice,
selections: &Selection,
regex: &crate::regex::Regex,
-) -> Selection {
+) -> Option<Selection> {
let mut result = SmallVec::with_capacity(selections.ranges().len());
for sel in selections.ranges() {
@@ -300,7 +300,11 @@ pub fn select_on_matches(
}
// TODO: figure out a new primary index
- Selection::new(result, 0)
+ if !result.is_empty() {
+ return Some(Selection::new(result, 0));
+ }
+
+ None
}
// TODO: support to split on capture #N instead of whole match
diff --git a/helix-core/src/transaction.rs b/helix-core/src/transaction.rs
index 000782dd..ce0174a6 100644
--- a/helix-core/src/transaction.rs
+++ b/helix-core/src/transaction.rs
@@ -314,10 +314,7 @@ impl ChangeSet {
/// `true` when the set is empty.
#[inline]
pub fn is_empty(&self) -> bool {
- match self.changes.as_slice() {
- [] | [Operation::Retain(_)] => true,
- _ => false,
- }
+ matches!(self.changes.as_slice(), [] | [Operation::Retain(_)])
}
/// Map a position through the changes.