From 9cac44c7c0f5696c8749fd8fdd32b8174723ab5d Mon Sep 17 00:00:00 2001 From: Blaž Hrastnik Date: Wed, 17 Feb 2021 14:41:43 +0900 Subject: minor changes --- helix-core/src/selection.rs | 8 ++++++-- helix-core/src/transaction.rs | 5 +---- 2 files changed, 7 insertions(+), 6 deletions(-) (limited to 'helix-core') 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 { 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. -- cgit v1.2.3-70-g09d2