summaryrefslogtreecommitdiff
path: root/helix-term
diff options
context:
space:
mode:
authorMichael Davis2023-07-11 00:09:26 +0000
committerBlaž Hrastnik2023-07-31 06:05:38 +0000
commita23b70182c5c714fb6210be7e6d4f4e3b15b0e8f (patch)
tree6ad35b1c54709515ae95367091a616c03927000e /helix-term
parentbaceb02a090fe711ad772d855635bc590826fa53 (diff)
commands: Allow using selected register where hardcoded
These snippets use hardcoded registers but it can be useful to be able to specify a register for these commands.
Diffstat (limited to 'helix-term')
-rw-r--r--helix-term/src/commands.rs15
1 files changed, 9 insertions, 6 deletions
diff --git a/helix-term/src/commands.rs b/helix-term/src/commands.rs
index d9ea580d..329b7ab7 100644
--- a/helix-term/src/commands.rs
+++ b/helix-term/src/commands.rs
@@ -1908,9 +1908,10 @@ fn searcher(cx: &mut Context, direction: Direction) {
fn search_next_or_prev_impl(cx: &mut Context, movement: Movement, direction: Direction) {
let count = cx.count();
+ let register = cx.register.unwrap_or('/');
let config = cx.editor.config();
let scrolloff = config.scrolloff;
- if let Some(query) = cx.editor.registers.last('/', cx.editor) {
+ if let Some(query) = cx.editor.registers.last(register, cx.editor) {
let doc = doc!(cx.editor);
let contents = doc.text().slice(..).to_string();
let search_config = &config.search;
@@ -1960,6 +1961,7 @@ fn extend_search_prev(cx: &mut Context) {
}
fn search_selection(cx: &mut Context) {
+ let register = cx.register.unwrap_or('/');
let (view, doc) = current!(cx.editor);
let contents = doc.text().slice(..);
@@ -1972,15 +1974,16 @@ fn search_selection(cx: &mut Context) {
.collect::<Vec<_>>()
.join("|");
- let msg = format!("register '{}' set to '{}'", '/', &regex);
- match cx.editor.registers.push('/', regex) {
+ let msg = format!("register '{}' set to '{}'", register, &regex);
+ match cx.editor.registers.push(register, regex) {
Ok(_) => cx.editor.set_status(msg),
Err(err) => cx.editor.set_error(err.to_string()),
}
}
fn make_search_word_bounded(cx: &mut Context) {
- let regex = match cx.editor.registers.last('/', cx.editor) {
+ let register = cx.register.unwrap_or('/');
+ let regex = match cx.editor.registers.last(register, cx.editor) {
Some(regex) => regex,
None => return,
};
@@ -2003,8 +2006,8 @@ fn make_search_word_bounded(cx: &mut Context) {
new_regex.push_str("\\b");
}
- let msg = format!("register '{}' set to '{}'", '/', &new_regex);
- match cx.editor.registers.push('/', new_regex) {
+ let msg = format!("register '{}' set to '{}'", register, &new_regex);
+ match cx.editor.registers.push(register, new_regex) {
Ok(_) => cx.editor.set_status(msg),
Err(err) => cx.editor.set_error(err.to_string()),
}