diff options
author | MilanVasko | 2022-07-27 09:02:19 +0000 |
---|---|---|
committer | GitHub | 2022-07-27 09:02:19 +0000 |
commit | 9a496237215dc09ef8f639fc79f7e63e2309c080 (patch) | |
tree | 744f81d351a48fe5eb2b2022fc712dd64f1d4ce4 /helix-term/src/commands.rs | |
parent | 846a6b65c3d13f49b571beee2189d17b71c92e3f (diff) |
Use OR of all selections in search_selection command (#3138)
Closes #2312
Diffstat (limited to 'helix-term/src/commands.rs')
-rw-r--r-- | helix-term/src/commands.rs | 12 |
1 files changed, 9 insertions, 3 deletions
diff --git a/helix-term/src/commands.rs b/helix-term/src/commands.rs index 3adb1f29..1c5cbf40 100644 --- a/helix-term/src/commands.rs +++ b/helix-term/src/commands.rs @@ -1748,10 +1748,16 @@ 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 regex = doc + .selection(view.id) + .iter() + .map(|selection| regex::escape(&selection.fragment(contents))) + .collect::<Vec<_>>() + .join("|"); + + let msg = format!("register '{}' set to '{}'", '/', ®ex); cx.editor.registers.get_mut('/').push(regex); - let msg = format!("register '{}' set to '{}'", '/', query); cx.editor.set_status(msg); } |