@@ -1895,7 +1895,9 @@ fn searcher(cx: &mut Context, direction: Direction) {
1895 .collect()
1895 .collect()
1897 move |editor, regex, event| {
1897 move |editor, regex, event| {
1898+ if event == PromptEvent::Validate {
1899+ editor.registers.last_search_register = reg;
1898− if !matches!(event, PromptEvent::Update | PromptEvent::Validate) {
1900+ } else if event != PromptEvent::Update {
1901 search_impl(
1903 search_impl(
@@ -1914,7 +1916,9 @@ fn searcher(cx: &mut Context, direction: Direction) {
1915fn search_next_or_prev_impl(cx: &mut Context, movement: Movement, direction: Direction) {
1917fn search_next_or_prev_impl(cx: &mut Context, movement: Movement, direction: Direction) {
1916 let count = cx.count();
1918 let count = cx.count();
1917− let register = cx.register.unwrap_or('/');
1919+ let register = cx
1921+ .unwrap_or(cx.editor.registers.last_search_register);
1918 let config = cx.editor.config();
1922 let config = cx.editor.config();
1919 let scrolloff = config.scrolloff;
1923 let scrolloff = config.scrolloff;
1920 if let Some(query) = cx.editor.registers.first(register, cx.editor) {
1924 if let Some(query) = cx.editor.registers.first(register, cx.editor) {
@@ -1982,13 +1986,21 @@ fn search_selection(cx: &mut Context) {
1983 let msg = format!("register '{}' set to '{}'", register, ®ex);
1987 let msg = format!("register '{}' set to '{}'", register, ®ex);
1984 match cx.editor.registers.push(register, regex) {
1988 match cx.editor.registers.push(register, regex) {
1990+ cx.editor.registers.last_search_register = register;
1985− Ok(_) => cx.editor.set_status(msg),
1991+ cx.editor.set_status(msg)
1986 Err(err) => cx.editor.set_error(err.to_string()),
1993 Err(err) => cx.editor.set_error(err.to_string()),
1990fn make_search_word_bounded(cx: &mut Context) {
1997fn make_search_word_bounded(cx: &mut Context) {
1998+ // Defaults to the active search register instead `/` to be more ergonomic assuming most people
1999+ // would use this command following `search_selection`. This avoids selecting the register
1991− let register = cx.register.unwrap_or('/');
2001+ let register = cx
2003+ .unwrap_or(cx.editor.registers.last_search_register);
1992 let regex = match cx.editor.registers.first(register, cx.editor) {
2004 let regex = match cx.editor.registers.first(register, cx.editor) {
1993 Some(regex) => regex,
2005 Some(regex) => regex,
1994 None => return,
2006 None => return,
@@ -2014,7 +2026,10 @@ fn make_search_word_bounded(cx: &mut Context) {
2015 let msg = format!("register '{}' set to '{}'", register, &new_regex);
2027 let msg = format!("register '{}' set to '{}'", register, &new_regex);
2016 match cx.editor.registers.push(register, new_regex) {
2028 match cx.editor.registers.push(register, new_regex) {
2030+ cx.editor.registers.last_search_register = register;
2017− Ok(_) => cx.editor.set_status(msg),
2031+ cx.editor.set_status(msg)
2018 Err(err) => cx.editor.set_error(err.to_string()),
2033 Err(err) => cx.editor.set_error(err.to_string()),
@@ -2078,6 +2093,7 @@ fn global_search(cx: &mut Context) {
2078 if event != PromptEvent::Validate {
2093 if event != PromptEvent::Validate {
2096+ editor.registers.last_search_register = reg;
2082 let documents: Vec<_> = editor
2098 let documents: Vec<_> = editor
2083 .documents()
2099 .documents()