Propagate the count and register to command palette commands

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.
This commit is contained in:
Michael Davis 2023-06-07 10:06:26 -05:00 committed by Blaž Hrastnik
parent 0e083497a5
commit b3949979ae

View file

@ -2705,6 +2705,9 @@ impl ui::menu::Item for MappableCommand {
} }
pub fn command_palette(cx: &mut Context) { pub fn command_palette(cx: &mut Context) {
let register = cx.register;
let count = cx.count;
cx.callback = Some(Box::new( cx.callback = Some(Box::new(
move |compositor: &mut Compositor, cx: &mut compositor::Context| { move |compositor: &mut Compositor, cx: &mut compositor::Context| {
let keymap = compositor.find::<ui::EditorView>().unwrap().keymaps.map() let keymap = compositor.find::<ui::EditorView>().unwrap().keymaps.map()
@ -2722,8 +2725,8 @@ pub fn command_palette(cx: &mut Context) {
let picker = Picker::new(commands, keymap, move |cx, command, _action| { let picker = Picker::new(commands, keymap, move |cx, command, _action| {
let mut ctx = Context { let mut ctx = Context {
register: None, register,
count: std::num::NonZeroUsize::new(1), count,
editor: cx.editor, editor: cx.editor,
callback: None, callback: None,
on_next_key_callback: None, on_next_key_callback: None,