Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Persist register selection in pending keymaps #7277

Merged
merged 2 commits into from
Jun 7, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
2 changes: 2 additions & 0 deletions helix-term/src/ui/editor.rs
Original file line number Diff line number Diff line change
Expand Up @@ -943,6 +943,8 @@ impl EditorView {
self.handle_keymap_event(mode, cxt, event);
if self.keymaps.pending().is_empty() {
cxt.editor.count = None
} else {
cxt.editor.selected_register = cxt.register.take();
}
}
}
Expand Down