@@ -1,7 +1,7 @@
11use helix_core::{
22 comment, graphemes,
33 indent::TAB_WIDTH,
4− regex::Regex,
4+ regex::{self, Regex},
55 register, selection,
66 state::{Direction, Granularity, State},
77 ChangeSet, Range, Selection, Tendril, Transaction,
@@ -412,6 +412,15 @@ pub fn search_next(cx: &mut Context) {
412412 }
413413}
414414
415+pub fn search_selection(cx: &mut Context) {
416+ let doc = cx.doc();
417+ let contents = doc.text().slice(..);
418+ let query = doc.selection().primary().fragment(contents);
419+ let regex = regex::escape(&query);
420+ register::set('\\', vec![regex]);
421+ search_next(cx);
422+}
423+
415424// TODO: N -> search_prev
416425// need to loop around buffer also and show a message
417426// same for no matches