From 032bf5212fcc2a57abf7a8e72b7d4e2f524a42f9 Mon Sep 17 00:00:00 2001 From: aiongg Date: Sun, 15 Nov 2026 12:57:09 +0000 Subject: [PATCH] fwb2-fix: commands::bindings reads the runtime keymap's keys for a command --- crates/ui-contract/src/runtime/commands/board.rs | 5 +++++ crates/ui-contract/src/runtime/commands/mod.rs | 6 ++++++ 2 files changed, 11 insertions(+) diff --git a/crates/ui-contract/src/runtime/commands/board.rs b/crates/ui-contract/src/runtime/commands/board.rs index c39dec99e..0b89102d3 100644 --- a/crates/ui-contract/src/runtime/commands/board.rs +++ b/crates/ui-contract/src/runtime/commands/board.rs @@ -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 { + 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()) diff --git a/crates/ui-contract/src/runtime/commands/mod.rs b/crates/ui-contract/src/runtime/commands/mod.rs index a4e417726..c8edc8f5f 100644 --- a/crates/ui-contract/src/runtime/commands/mod.rs +++ b/crates/ui-contract/src/runtime/commands/mod.rs @@ -442,6 +442,12 @@ pub fn resolve(ctx: &Context, command: impl Into) -> 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 { + 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`].