aboutsummaryrefslogtreecommitdiff
path: root/helix-core
diff options
context:
space:
mode:
authorBlaž Hrastnik2021-02-17 05:41:43 +0000
committerBlaž Hrastnik2021-02-17 08:26:27 +0000
commit9cac44c7c0f5696c8749fd8fdd32b8174723ab5d (patch)
treea884a5a2ca40a1fdb017a4c031996d9878860ab3 /helix-core
parent8e1a59c1408597484aeff7f96a09f1a1d10c76f6 (diff)
minor changes
Diffstat (limited to 'helix-core')
-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.