Add keystroke for menu item only when action is equal to binding
This fixes a bug where we would show `cmd-e` instead of `cmd-f` for `Edit -> Find` because both bindings would have the `buffer_search::Deploy` action and we were mistakenly selecting the former.
This commit is contained in:
parent
3a69943df3
commit
22dd68fbfb
2 changed files with 6 additions and 2 deletions
|
@ -176,7 +176,7 @@ impl Matcher {
|
||||||
cx: &Context,
|
cx: &Context,
|
||||||
) -> Option<SmallVec<[Keystroke; 2]>> {
|
) -> Option<SmallVec<[Keystroke; 2]>> {
|
||||||
for binding in self.keymap.bindings.iter().rev() {
|
for binding in self.keymap.bindings.iter().rev() {
|
||||||
if binding.action.id() == action.id()
|
if binding.action.eq(action)
|
||||||
&& binding
|
&& binding
|
||||||
.context_predicate
|
.context_predicate
|
||||||
.as_ref()
|
.as_ref()
|
||||||
|
@ -265,6 +265,10 @@ impl Binding {
|
||||||
pub fn keystrokes(&self) -> &[Keystroke] {
|
pub fn keystrokes(&self) -> &[Keystroke] {
|
||||||
&self.keystrokes
|
&self.keystrokes
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub fn action(&self) -> &dyn Action {
|
||||||
|
self.action.as_ref()
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Keystroke {
|
impl Keystroke {
|
||||||
|
|
|
@ -154,7 +154,7 @@ impl MacForegroundPlatform {
|
||||||
let mut keystroke = None;
|
let mut keystroke = None;
|
||||||
if let Some(binding) = keystroke_matcher
|
if let Some(binding) = keystroke_matcher
|
||||||
.bindings_for_action_type(action.as_any().type_id())
|
.bindings_for_action_type(action.as_any().type_id())
|
||||||
.next()
|
.find(|binding| binding.action().eq(action.as_ref()))
|
||||||
{
|
{
|
||||||
if binding.keystrokes().len() == 1 {
|
if binding.keystrokes().len() == 1 {
|
||||||
keystroke = binding.keystrokes().first()
|
keystroke = binding.keystrokes().first()
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue