Skip to content

Commit

Permalink
Propagate the count and register to command palette commands
Browse files Browse the repository at this point in the history
Previously a count or register selection would be lost while opening
the command palette. This change allows using a register selection or
count in any command chosen from the command palette.
  • Loading branch information
the-mikedavis authored and archseer committed Jun 7, 2023
1 parent 0e08349 commit b394997
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions helix-term/src/commands.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2705,6 +2705,9 @@ impl ui::menu::Item for MappableCommand {
}

pub fn command_palette(cx: &mut Context) {
let register = cx.register;
let count = cx.count;

cx.callback = Some(Box::new(
move |compositor: &mut Compositor, cx: &mut compositor::Context| {
let keymap = compositor.find::<ui::EditorView>().unwrap().keymaps.map()
Expand All @@ -2722,8 +2725,8 @@ pub fn command_palette(cx: &mut Context) {

let picker = Picker::new(commands, keymap, move |cx, command, _action| {
let mut ctx = Context {
register: None,
count: std::num::NonZeroUsize::new(1),
register,
count,
editor: cx.editor,
callback: None,
on_next_key_callback: None,
Expand Down

0 comments on commit b394997

Please sign in to comment.