Skip to content

Commit

Permalink
Use OR of all selections in search_selection command
Browse files Browse the repository at this point in the history
Closes #2312
  • Loading branch information
MilanVasko committed Jul 21, 2022
1 parent 76756f0 commit b360156
Showing 1 changed file with 10 additions and 3 deletions.
13 changes: 10 additions & 3 deletions helix-term/src/commands.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1747,10 +1747,17 @@ fn extend_search_prev(cx: &mut Context) {
fn search_selection(cx: &mut Context) {
let (view, doc) = current!(cx.editor);
let contents = doc.text().slice(..);
let query = doc.selection(view.id).primary().fragment(contents);
let regex = regex::escape(&query);

let mut regex = String::new();
for (index, selection) in doc.selection(view.id).iter().enumerate() {
if index > 0 {
regex += "|";
}
let query = selection.fragment(contents);
regex += &regex::escape(&query);
}
let msg = format!("register '{}' set to '{}'", '/', &regex);
cx.editor.registers.get_mut('/').push(regex);
let msg = format!("register '{}' set to '{}'", '/', query);
cx.editor.set_status(msg);
}

Expand Down

0 comments on commit b360156

Please sign in to comment.