aboutsummaryrefslogtreecommitdiff
path: root/helix-term/src/commands.rs
diff options
context:
space:
mode:
authorBlaž Hrastnik2021-03-15 08:09:18 +0000
committerBlaž Hrastnik2021-03-15 08:09:18 +0000
commitdd91090a1ae931a604c51b9c6d7d8c9b46761af4 (patch)
tree3a399be8dba630a20c84a960e8aeb421c025dbac /helix-term/src/commands.rs
parent872d77075302a3f5b526045e07e0a5564d170e1b (diff)
Implement keep_selections (filter selections on regex).
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));
}
//