Skip to content

Commit a55dff7

Browse files
authored
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 <img width="712" height="264" alt="Screenshot 2025-09-26 at 16 57 08" src="https://github.com/user-attachments/assets/62bc24bd-c335-420f-9c2e-3690031518c1" /> ### After <img width="712" height="264" alt="Screenshot 2025-09-26 at 17 13 50" src="https://github.com/user-attachments/assets/e0088897-eb6b-4d7b-855a-931adcc15fe8" />
1 parent 6db621a commit a55dff7

File tree

1 file changed

+3
-4
lines changed

1 file changed

+3
-4
lines changed

crates/ui/src/components/keybinding.rs

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -392,7 +392,7 @@ pub fn text_for_action(action: &dyn Action, window: &Window, cx: &App) -> Option
392392

393393
pub fn text_for_keystrokes(keystrokes: &[Keystroke], cx: &App) -> String {
394394
let platform_style = PlatformStyle::platform();
395-
let vim_enabled = cx.try_global::<VimStyle>().is_some();
395+
let vim_enabled = KeyBinding::is_vim_mode(cx);
396396
keystrokes
397397
.iter()
398398
.map(|keystroke| {
@@ -408,7 +408,7 @@ pub fn text_for_keystrokes(keystrokes: &[Keystroke], cx: &App) -> String {
408408

409409
pub fn text_for_keybinding_keystrokes(keystrokes: &[KeybindingKeystroke], cx: &App) -> String {
410410
let platform_style = PlatformStyle::platform();
411-
let vim_enabled = cx.try_global::<VimStyle>().is_some();
411+
let vim_enabled = KeyBinding::is_vim_mode(cx);
412412
keystrokes
413413
.iter()
414414
.map(|keystroke| {
@@ -424,8 +424,7 @@ pub fn text_for_keybinding_keystrokes(keystrokes: &[KeybindingKeystroke], cx: &A
424424

425425
pub fn text_for_keystroke(modifiers: &Modifiers, key: &str, cx: &App) -> String {
426426
let platform_style = PlatformStyle::platform();
427-
let vim_enabled = cx.try_global::<VimStyle>().is_some();
428-
keystroke_text(modifiers, key, platform_style, vim_enabled)
427+
keystroke_text(modifiers, key, platform_style, KeyBinding::is_vim_mode(cx))
429428
}
430429

431430
/// Returns a textual representation of the given [`Keystroke`].

0 commit comments

Comments
 (0)