Improve doc comments about keybinding order (#23014)

Release Notes:

- N/A
This commit is contained in:
Michael Sloan 2025-01-11 15:47:42 -07:00 committed by GitHub
parent daaa250109
commit 5785266c8c
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
4 changed files with 28 additions and 19 deletions

View file

@ -16,13 +16,14 @@ pub struct KeyBinding {
}
impl KeyBinding {
/// Returns the highest precedence keybinding for an action. This is the last binding added to
/// the keymap. User bindings are added after built-in bindings so that they take precedence.
pub fn for_action(action: &dyn Action, cx: &mut WindowContext) -> Option<Self> {
let key_binding = cx.bindings_for_action(action).last().cloned()?;
Some(Self::new(key_binding))
}
// like for_action(), but lets you specify the context from which keybindings
// are matched.
/// Like `for_action`, but lets you specify the context from which keybindings are matched.
pub fn for_action_in(
action: &dyn Action,
focus: &FocusHandle,