on master help sign in
commands: Allow using selected register where hardcoded
a23b701Michael Davis
helix-term/src/commands.rs+9−6
@@ -1908,9 +1908,10 @@ fn searcher(cx: &mut Context, direction: Direction) {
1908
1908
1909fn search_next_or_prev_impl(cx: &mut Context, movement: Movement, direction: Direction) {
1909fn search_next_or_prev_impl(cx: &mut Context, movement: Movement, direction: Direction) {
1910 let count = cx.count();
1910 let count = cx.count();
1911+ let register = cx.register.unwrap_or('/');
1911 let config = cx.editor.config();
1912 let config = cx.editor.config();
1912 let scrolloff = config.scrolloff;
1913 let scrolloff = config.scrolloff;
1913− if let Some(query) = cx.editor.registers.last('/', cx.editor) {
1914+ if let Some(query) = cx.editor.registers.last(register, cx.editor) {
1914 let doc = doc!(cx.editor);
1915 let doc = doc!(cx.editor);
1915 let contents = doc.text().slice(..).to_string();
1916 let contents = doc.text().slice(..).to_string();
1916 let search_config = &config.search;
1917 let search_config = &config.search;
@@ -1960,6 +1961,7 @@ fn extend_search_prev(cx: &mut Context) {
1960}
1961}
1961
1962
1962fn search_selection(cx: &mut Context) {
1963fn search_selection(cx: &mut Context) {
1964+ let register = cx.register.unwrap_or('/');
1963 let (view, doc) = current!(cx.editor);
1965 let (view, doc) = current!(cx.editor);
1964 let contents = doc.text().slice(..);
1966 let contents = doc.text().slice(..);
1965
1967
@@ -1972,15 +1974,16 @@ fn search_selection(cx: &mut Context) {
1972 .collect::<Vec<_>>()
1974 .collect::<Vec<_>>()
1973 .join("|");
1975 .join("|");
1974
1976
1975− let msg = format!("register '{}' set to '{}'", '/', &regex);
1977+ let msg = format!("register '{}' set to '{}'", register, &regex);
1976− match cx.editor.registers.push('/', regex) {
1978+ match cx.editor.registers.push(register, regex) {
1977 Ok(_) => cx.editor.set_status(msg),
1979 Ok(_) => cx.editor.set_status(msg),
1978 Err(err) => cx.editor.set_error(err.to_string()),
1980 Err(err) => cx.editor.set_error(err.to_string()),
1979 }
1981 }
1980}
1982}
1981
1983
1982fn make_search_word_bounded(cx: &mut Context) {
1984fn make_search_word_bounded(cx: &mut Context) {
1985+ let register = cx.register.unwrap_or('/');
1983− let regex = match cx.editor.registers.last('/', cx.editor) {
1986+ let regex = match cx.editor.registers.last(register, cx.editor) {
1984 Some(regex) => regex,
1987 Some(regex) => regex,
1985 None => return,
1988 None => return,
1986 };
1989 };
@@ -2003,8 +2006,8 @@ fn make_search_word_bounded(cx: &mut Context) {
2003 new_regex.push_str("\\b");
2006 new_regex.push_str("\\b");
2004 }
2007 }
2005
2008
2006− let msg = format!("register '{}' set to '{}'", '/', &new_regex);
2009+ let msg = format!("register '{}' set to '{}'", register, &new_regex);
2007− match cx.editor.registers.push('/', new_regex) {
2010+ match cx.editor.registers.push(register, new_regex) {
2008 Ok(_) => cx.editor.set_status(msg),
2011 Ok(_) => cx.editor.set_status(msg),
2009 Err(err) => cx.editor.set_error(err.to_string()),
2012 Err(err) => cx.editor.set_error(err.to_string()),
2010 }
2013 }