From a7f45cc97a5664b5b17098a4ff9468beed4d1c54 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Milan=20Va=C5=A1ko?= Date: Sat, 16 Jul 2022 15:07:38 +0200 Subject: [PATCH] Use OR of all selections in search_selection command Closes #2312 --- helix-term/src/commands.rs | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/helix-term/src/commands.rs b/helix-term/src/commands.rs index 3adb1f29b901..1c5cbf400d88 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::>() + .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); }