Skip to content

Commit e330f90

Browse files
claudesinelaw
authored andcommitted
fix: use consistent keybinding display in menus (#703)
Menu keybinding display was using a local format_keybinding method that didn't respect macOS symbols (always showed "Alt" instead of "⌥"). Fix: - Remove duplicate local format_keybinding method - Use the public format_keybinding function that properly handles platform-specific symbols (⌥ for Alt on macOS, Alt elsewhere) This ensures consistent keyboard shortcut display between menus and status bar, particularly on macOS where Alt should be shown as ⌥.
1 parent 96fcd6e commit e330f90

1 file changed

Lines changed: 1 addition & 40 deletions

File tree

src/input/keybindings.rs

Lines changed: 1 addition & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -1346,7 +1346,7 @@ impl KeybindingResolver {
13461346
});
13471347

13481348
let (key_code, modifiers) = matches[0];
1349-
return Some(Self::format_keybinding(key_code, modifiers));
1349+
return Some(format_keybinding(&key_code, &modifiers));
13501350
}
13511351
}
13521352

@@ -1403,45 +1403,6 @@ impl KeybindingResolver {
14031403
None
14041404
}
14051405

1406-
/// Format a keybinding for display (e.g., "Ctrl+S", "Alt+Enter", "F12")
1407-
fn format_keybinding(key_code: KeyCode, modifiers: KeyModifiers) -> String {
1408-
let mut parts = Vec::new();
1409-
1410-
if modifiers.contains(KeyModifiers::CONTROL) {
1411-
parts.push("Ctrl");
1412-
}
1413-
if modifiers.contains(KeyModifiers::ALT) {
1414-
parts.push("Alt");
1415-
}
1416-
if modifiers.contains(KeyModifiers::SHIFT) {
1417-
parts.push("Shift");
1418-
}
1419-
1420-
// Format the key
1421-
let key_str = match key_code {
1422-
KeyCode::Char(c) if c == ' ' => "Space".to_string(),
1423-
KeyCode::Char(c) => c.to_uppercase().to_string(),
1424-
KeyCode::Enter => "Enter".to_string(),
1425-
KeyCode::Backspace => "Backspace".to_string(),
1426-
KeyCode::Delete => "Delete".to_string(),
1427-
KeyCode::Tab => "Tab".to_string(),
1428-
KeyCode::Esc => "Esc".to_string(),
1429-
KeyCode::Left => "Left".to_string(),
1430-
KeyCode::Right => "Right".to_string(),
1431-
KeyCode::Up => "Up".to_string(),
1432-
KeyCode::Down => "Down".to_string(),
1433-
KeyCode::Home => "Home".to_string(),
1434-
KeyCode::End => "End".to_string(),
1435-
KeyCode::PageUp => "PageUp".to_string(),
1436-
KeyCode::PageDown => "PageDown".to_string(),
1437-
KeyCode::F(n) => format!("F{}", n),
1438-
_ => return String::new(),
1439-
};
1440-
1441-
parts.push(&key_str);
1442-
parts.join("+")
1443-
}
1444-
14451406
/// Parse a key string to KeyCode
14461407
fn parse_key(key: &str) -> Option<KeyCode> {
14471408
let lower = key.to_lowercase();

0 commit comments

Comments
 (0)