Skip to content

Commit

Permalink
feat(commands): add clear_registers command
Browse files Browse the repository at this point in the history
  • Loading branch information
Jorge committed Jan 30, 2023
1 parent 447909e commit 76277a4
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 0 deletions.
1 change: 1 addition & 0 deletions book/src/keymap.md
Original file line number Diff line number Diff line change
Expand Up @@ -289,6 +289,7 @@ This layer is a kludge of mappings, mostly pickers.
| `Y` | Yank main selection to clipboard | `yank_main_selection_to_clipboard` |
| `R` | Replace selections by clipboard contents | `replace_selections_with_clipboard` |
| `/` | Global search in workspace folder | `global_search` |
| `|` | Clear all registers | `clear_registers` |
| `?` | Open command palette | `command_palette` |

> TIP: Global search displays results in a fuzzy picker, use `Space + '` to bring it back up after opening a file.
Expand Down
4 changes: 4 additions & 0 deletions helix-core/src/register.rs
Original file line number Diff line number Diff line change
Expand Up @@ -78,4 +78,8 @@ impl Registers {
pub fn inner(&self) -> &HashMap<char, Register> {
&self.inner
}

pub fn clear(&mut self) {
self.inner.clear();
}
}
7 changes: 7 additions & 0 deletions helix-term/src/commands.rs
Original file line number Diff line number Diff line change
Expand Up @@ -392,6 +392,7 @@ impl MappableCommand {
wonly, "Close windows except current",
select_register, "Select register",
insert_register, "Insert register",
clear_registers, "Clear registers",
align_view_middle, "Align view middle",
align_view_top, "Align view top",
align_view_center, "Align view center",
Expand Down Expand Up @@ -4457,6 +4458,12 @@ fn insert_register(cx: &mut Context) {
})
}

fn clear_registers(cx: &mut Context) {
cx.editor.autoinfo = None;
cx.editor.registers.clear();
cx.editor.set_status("All registers cleared.")
}

fn align_view_top(cx: &mut Context) {
let (view, doc) = current!(cx.editor);
align_view(doc, view, Align::Top);
Expand Down
1 change: 1 addition & 0 deletions helix-term/src/keymap/default.rs
Original file line number Diff line number Diff line change
Expand Up @@ -269,6 +269,7 @@ pub fn default() -> HashMap<Mode, Keymap> {
"k" => hover,
"r" => rename_symbol,
"h" => select_references_to_symbol_under_cursor,
"|" => clear_registers,
"?" => command_palette,
},
"z" => { "View"
Expand Down

0 comments on commit 76277a4

Please sign in to comment.