From 4031bedee59519c3cd2056738fdbeee195e1bf2d Mon Sep 17 00:00:00 2001 From: "gcp-cherry-pick-bot[bot]" <98988430+gcp-cherry-pick-bot[bot]@users.noreply.github.com> Date: Mon, 28 Jul 2025 18:02:00 -0400 Subject: [PATCH] keymap_ui: Fix bug introduced in #35208 (cherry-pick #35237) (#35240) Cherry-picked keymap_ui: Fix bug introduced in #35208 (#35237) Closes #ISSUE Fixes a bug that was cherry picked onto stable and preview branches introduced in #35208 whereby modifier keys would show up and not be removable when editing a keybind Release Notes: - (preview only) Keymap Editor: Fixed an issue introduced in v0.197.2 whereby modifier keys would show up and not be removable while recording keystrokes in the keybind edit modal Co-authored-by: Ben Kunkle --- crates/gpui/src/platform/keystroke.rs | 6 +----- crates/settings_ui/src/keybindings.rs | 4 +++- 2 files changed, 4 insertions(+), 6 deletions(-) diff --git a/crates/gpui/src/platform/keystroke.rs b/crates/gpui/src/platform/keystroke.rs index 0f8dbdf9d2..24601eefd6 100644 --- a/crates/gpui/src/platform/keystroke.rs +++ b/crates/gpui/src/platform/keystroke.rs @@ -534,11 +534,7 @@ impl Modifiers { /// Checks if this [`Modifiers`] is a subset of another [`Modifiers`]. pub fn is_subset_of(&self, other: &Modifiers) -> bool { - (other.control || !self.control) - && (other.alt || !self.alt) - && (other.shift || !self.shift) - && (other.platform || !self.platform) - && (other.function || !self.function) + (*other & *self) == *self } } diff --git a/crates/settings_ui/src/keybindings.rs b/crates/settings_ui/src/keybindings.rs index 431daff203..9da7242e36 100644 --- a/crates/settings_ui/src/keybindings.rs +++ b/crates/settings_ui/src/keybindings.rs @@ -3109,7 +3109,9 @@ impl KeystrokeInput { ) { let keystrokes_len = self.keystrokes.len(); - if event.modifiers.is_subset_of(&self.previous_modifiers) { + if self.previous_modifiers.modified() + && event.modifiers.is_subset_of(&self.previous_modifiers) + { self.previous_modifiers &= event.modifiers; cx.stop_propagation(); return;