aboutsummaryrefslogtreecommitdiff
path: root/helix-term/src/commands.rs
diff options
context:
space:
mode:
Diffstat (limited to 'helix-term/src/commands.rs')
-rw-r--r--helix-term/src/commands.rs10
1 files changed, 9 insertions, 1 deletions
diff --git a/helix-term/src/commands.rs b/helix-term/src/commands.rs
index 36edde4c..d75fd694 100644
--- a/helix-term/src/commands.rs
+++ b/helix-term/src/commands.rs
@@ -1156,7 +1156,15 @@ pub fn join_selections(cx: &mut Context) {
pub fn keep_selections(cx: &mut Context) {
let doc = cx.doc();
// keep selections matching regex
- // and another method for inverse
+ let prompt = ui::regex_prompt(cx, "keep:".to_string(), |doc, regex| {
+ let text = doc.text().slice(..);
+
+ if let Some(selection) = selection::keep_matches(text, doc.selection(), &regex) {
+ doc.set_selection(selection);
+ }
+ });
+
+ cx.push_layer(Box::new(prompt));
}
//