From a55dff78342cff9a0cf18e283b3a5b78846c82de Mon Sep 17 00:00:00 2001 From: Bartosz Kaszubowski Date: Fri, 26 Sep 2025 18:18:49 +0200 Subject: [PATCH] ui: Fix Vim mode detection in keybinding to text helpers (#38971) # Why Refs: * #38969 When working on the PR above I have spotted that keybinding to text helpers incorrectly detects if Vim mode is enabled. # How Replace inline check with an existing `KeyBinding::is_vim_mode` method in keybinding text helpers. Release Notes: - Fixed incorrect Vim mode detection in UI keybinding to text helpers. # Test plan Made sure that when Vim mode is not specified in settings file it resolves to `false`, and correct keybindings are displayed, than I have added the `"vim_mode": true,` line to my settings file and made sure that keybindings text have changed accordingly. ### Before Screenshot 2025-09-26 at 16 57 08 ### After Screenshot 2025-09-26 at 17 13 50 --- crates/ui/src/components/keybinding.rs | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/crates/ui/src/components/keybinding.rs b/crates/ui/src/components/keybinding.rs index 76bd128ed80ada2d8a2606963943de3d5db2cc07..f8ac85528ec3317bb003d3f8763f8c57a7d4bba2 100644 --- a/crates/ui/src/components/keybinding.rs +++ b/crates/ui/src/components/keybinding.rs @@ -392,7 +392,7 @@ pub fn text_for_action(action: &dyn Action, window: &Window, cx: &App) -> Option pub fn text_for_keystrokes(keystrokes: &[Keystroke], cx: &App) -> String { let platform_style = PlatformStyle::platform(); - let vim_enabled = cx.try_global::().is_some(); + let vim_enabled = KeyBinding::is_vim_mode(cx); keystrokes .iter() .map(|keystroke| { @@ -408,7 +408,7 @@ pub fn text_for_keystrokes(keystrokes: &[Keystroke], cx: &App) -> String { pub fn text_for_keybinding_keystrokes(keystrokes: &[KeybindingKeystroke], cx: &App) -> String { let platform_style = PlatformStyle::platform(); - let vim_enabled = cx.try_global::().is_some(); + let vim_enabled = KeyBinding::is_vim_mode(cx); keystrokes .iter() .map(|keystroke| { @@ -424,8 +424,7 @@ pub fn text_for_keybinding_keystrokes(keystrokes: &[KeybindingKeystroke], cx: &A pub fn text_for_keystroke(modifiers: &Modifiers, key: &str, cx: &App) -> String { let platform_style = PlatformStyle::platform(); - let vim_enabled = cx.try_global::().is_some(); - keystroke_text(modifiers, key, platform_style, vim_enabled) + keystroke_text(modifiers, key, platform_style, KeyBinding::is_vim_mode(cx)) } /// Returns a textual representation of the given [`Keystroke`].