summaryrefslogtreecommitdiff
path: root/helix-core
diff options
context:
space:
mode:
Diffstat (limited to 'helix-core')
-rw-r--r--helix-core/src/selection.rs5
1 files changed, 3 insertions, 2 deletions
diff --git a/helix-core/src/selection.rs b/helix-core/src/selection.rs
index f3b5d2c8..f7c7dbcb 100644
--- a/helix-core/src/selection.rs
+++ b/helix-core/src/selection.rs
@@ -528,14 +528,15 @@ impl<'a> IntoIterator for &'a Selection {
// TODO: checkSelection -> check if valid for doc length && sorted
-pub fn keep_matches(
+pub fn keep_or_remove_matches(
text: RopeSlice,
selection: &Selection,
regex: &crate::regex::Regex,
+ remove: bool,
) -> Option<Selection> {
let result: SmallVec<_> = selection
.iter()
- .filter(|range| regex.is_match(&range.fragment(text)))
+ .filter(|range| regex.is_match(&range.fragment(text)) ^ remove)
.copied()
.collect();