aboutsummaryrefslogtreecommitdiff
path: root/helix-core/src
diff options
context:
space:
mode:
authorOmnikar2021-11-12 00:34:08 +0000
committerGitHub2021-11-12 00:34:08 +0000
commitbf95a9ed043242d95e431412e45e218d40a5695a (patch)
treeb3b141542fd05f088fabadeb67681dcd560bdbe2 /helix-core/src
parent9d591427be900b7a43fc7e13dd86f31199e8c00e (diff)
Add `remove_selections` command (#1065)
* Add `remove_selections` command * Document `remove_selections` * Update helix-term/src/keymap.rs Co-authored-by: Blaž Hrastnik <blaz@mxxn.io>
Diffstat (limited to 'helix-core/src')
-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();