@@ -250,6 +250,7 @@ impl MappableCommand {
250 extend_search_next, "Add next search match to selection",
250 extend_search_next, "Add next search match to selection",
251 extend_search_prev, "Add previous search match to selection",
251 extend_search_prev, "Add previous search match to selection",
252 search_selection, "Use current selection as search pattern",
252 search_selection, "Use current selection as search pattern",
253+ make_search_word_bounded, "Modify current search to make it word bounded",
253 global_search, "Global search in workspace folder",
254 global_search, "Global search in workspace folder",
254 extend_line, "Select current line, if already selected, extend to another line based on the anchor",
255 extend_line, "Select current line, if already selected, extend to another line based on the anchor",
255 extend_line_below, "Select current line, if already selected, extend to next line",
256 extend_line_below, "Select current line, if already selected, extend to next line",
@@ -1809,6 +1810,35 @@ fn search_selection(cx: &mut Context) {
1809 cx.editor.set_status(msg);
1810 cx.editor.set_status(msg);
1813+fn make_search_word_bounded(cx: &mut Context) {
1814+ let regex = match cx.editor.registers.last('/') {
1815+ Some(regex) => regex,
1818+ let start_anchored = regex.starts_with("\\b");
1819+ let end_anchored = regex.ends_with("\\b");
1821+ if start_anchored && end_anchored {
1825+ let mut new_regex = String::with_capacity(
1826+ regex.len() + if start_anchored { 0 } else { 2 } + if end_anchored { 0 } else { 2 },
1829+ if !start_anchored {
1830+ new_regex.push_str("\\b");
1832+ new_regex.push_str(regex);
1834+ new_regex.push_str("\\b");
1837+ let msg = format!("register '{}' set to '{}'", '/', &new_regex);
1838+ cx.editor.registers.get_mut('/').push(new_regex);
1839+ cx.editor.set_status(msg);
1812fn global_search(cx: &mut Context) {
1842fn global_search(cx: &mut Context) {
1813 #[derive(Debug)]
1843 #[derive(Debug)]
1814 struct FileResult {
1844 struct FileResult {