Centralize logic around which keybind to display (#25215)
Closes #24931 We've flipped back and forth at least once on whether the last or first added keybinding should be shown in different contexts (See [this](https://github.com/zed-industries/zed/issues/23621#issuecomment-2614061385) as well as #23621 and the subsequent #23660) This PR attempts to pick a side to stick with so that we are at least consistent until #23660 is resolved and we have a way to determine which keybinds to display in a manner that is both consistent and not confusing Release Notes: - N/A
This commit is contained in:
parent
d4392aaf2d
commit
b84aec0fae
3 changed files with 30 additions and 19 deletions
|
@ -30,11 +30,9 @@ 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, window: &mut Window, cx: &App) -> Option<Self> {
|
||||
let key_binding = window
|
||||
.bindings_for_action(action)
|
||||
.into_iter()
|
||||
.rev()
|
||||
.next()?;
|
||||
let key_binding =
|
||||
gpui::Keymap::binding_to_display_from_bindings(&window.bindings_for_action(action))
|
||||
.cloned()?;
|
||||
Some(Self::new(key_binding, cx))
|
||||
}
|
||||
|
||||
|
@ -45,11 +43,10 @@ impl KeyBinding {
|
|||
window: &mut Window,
|
||||
cx: &App,
|
||||
) -> Option<Self> {
|
||||
let key_binding = window
|
||||
.bindings_for_action_in(action, focus)
|
||||
.into_iter()
|
||||
.rev()
|
||||
.next()?;
|
||||
let key_binding = gpui::Keymap::binding_to_display_from_bindings(
|
||||
&window.bindings_for_action_in(action, focus),
|
||||
)
|
||||
.cloned()?;
|
||||
Some(Self::new(key_binding, cx))
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue