aboutsummaryrefslogtreecommitdiff
path: root/helix-term/src/commands.rs
diff options
context:
space:
mode:
authorBlaž Hrastnik2021-02-22 06:14:02 +0000
committerBlaž Hrastnik2021-02-22 06:14:02 +0000
commit33c67f138835d4407e076ebcf2d29322fda44114 (patch)
tree0bffdeab32e8b6be019d5ee9974e6654fefb296e /helix-term/src/commands.rs
parent61ce2c9cfe07f1cb0b6a6bfd7136b63d667b6795 (diff)
commands: add * as selection search.
Diffstat (limited to 'helix-term/src/commands.rs')
-rw-r--r--helix-term/src/commands.rs11
1 files changed, 10 insertions, 1 deletions
diff --git a/helix-term/src/commands.rs b/helix-term/src/commands.rs
index b6d8d818..c048ff9a 100644
--- a/helix-term/src/commands.rs
+++ b/helix-term/src/commands.rs
@@ -1,7 +1,7 @@
use helix_core::{
comment, graphemes,
indent::TAB_WIDTH,
- regex::Regex,
+ regex::{self, Regex},
register, selection,
state::{Direction, Granularity, State},
ChangeSet, Range, Selection, Tendril, Transaction,
@@ -412,6 +412,15 @@ pub fn search_next(cx: &mut Context) {
}
}
+pub fn search_selection(cx: &mut Context) {
+ let doc = cx.doc();
+ let contents = doc.text().slice(..);
+ let query = doc.selection().primary().fragment(contents);
+ let regex = regex::escape(&query);
+ register::set('\\', vec![regex]);
+ search_next(cx);
+}
+
// TODO: N -> search_prev
// need to loop around buffer also and show a message
// same for no matches