Skip to main content

translate_mode_keymaps

Function translate_mode_keymaps 

Source
pub fn translate_mode_keymaps(
    handle: &KeymapHandle,
    registry: &ModeRegistry,
    command_registry: &CommandRegistry,
)
Expand description

Walk every mode in registry, call Mode::keymap(), and push each non-empty contribution as a MinorMode(mode_id) layer on handle.

Boot-path entry. Runs exactly once at editor boot, after the ModeRegistry is fully populated (so every mode that registered before boot completion contributes its bindings before the first keystroke). Modes whose keymap() returns Keymap::default() (the empty contribution) are skipped — no layer is pushed for them, so registry merge cost stays O(modes-with-bindings), not O(all-modes).

command_registry is needed to resolve any table-form entries (Keymap::entries) into typed CommandInvocations; chain-form bindings (Keymap::bindings) skip the registry walk because they already carry an invocation.

Re-running the pass is safe (push_layer for a MinorMode(mode_id) is idempotent-on-identity per K.1.b: re-pushing the same mode_id replaces the layer’s bindings rather than minting a sibling).