fwb2-fix: commands::bindings reads the runtime keymap's keys for a command

This commit is contained in:
aiongg
2026-11-15 12:59:34 +00:00
parent a6f2c6c892
commit 032bf5212f
2 changed files with 11 additions and 0 deletions
@@ -613,6 +613,11 @@ pub(crate) fn edit_chords(ctx: &Context) -> Arc<[(EditCommand, Chord)]> {
with(ctx, |board| board.keymap.as_ref().map(|cache| Arc::clone(&cache.edit_chords)).unwrap_or_default())
}
/// The bindings the window's keymap gives `command`; none before the first frame builds one.
pub(crate) fn bindings(ctx: &Context, command: &CommandRef) -> Vec<craft_keymap::Binding> {
with(ctx, |board| board.keymap.as_ref().map(|cache| cache.keymap.bindings(command)).unwrap_or_default())
}
/// The chords bound to the window's keys, which the input hook takes before any component.
pub(crate) fn window_shortcuts(ctx: &Context) -> Arc<[(WindowShortcut, Chord)]> {
with(ctx, |board| board.keymap.as_ref().map(|cache| Arc::clone(&cache.window_shortcuts)).unwrap_or_default())
@@ -442,6 +442,12 @@ pub fn resolve(ctx: &Context, command: impl Into<CommandRef>) -> ResolvedCommand
board::resolve_global(ctx, &command.into())
}
/// The keys `command` has in the runtime's keymap: its defaults under the user's overrides (`CommandInput`), on the
/// window's platform, double presses included. Empty before the first frame.
pub fn bindings(ctx: &Context, command: &CommandRef) -> Vec<Binding> {
board::bindings(ctx, command)
}
/// `command` as [`resolve`] shows it, from the window under the modal layer whose body is running, as that window is
/// once the layer closes: for a surface that closes before its command runs (the command palette), whose own layer
/// does not block the command. Outside a modal layer it is [`resolve`].