Don't display MacOS key symbols in Linux (#29016)
Release Notes: - Fix MacOS key symbols being displayed in other platforms.
This commit is contained in:
parent
6e0732a9d7
commit
6ffd3f034f
2 changed files with 27 additions and 20 deletions
|
@ -318,10 +318,18 @@ fn is_printable_key(key: &str) -> bool {
|
||||||
impl std::fmt::Display for Keystroke {
|
impl std::fmt::Display for Keystroke {
|
||||||
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
|
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
|
||||||
if self.modifiers.control {
|
if self.modifiers.control {
|
||||||
f.write_char('^')?;
|
if cfg!(target_os = "macos") {
|
||||||
|
f.write_char('^')?;
|
||||||
|
} else {
|
||||||
|
write!(f, "ctrl-")?;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
if self.modifiers.alt {
|
if self.modifiers.alt {
|
||||||
f.write_char('⌥')?;
|
if cfg!(target_os = "macos") {
|
||||||
|
f.write_char('⌥')?;
|
||||||
|
} else {
|
||||||
|
write!(f, "alt-")?;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
if self.modifiers.platform {
|
if self.modifiers.platform {
|
||||||
#[cfg(target_os = "macos")]
|
#[cfg(target_os = "macos")]
|
||||||
|
@ -334,20 +342,24 @@ impl std::fmt::Display for Keystroke {
|
||||||
f.write_char('⊞')?;
|
f.write_char('⊞')?;
|
||||||
}
|
}
|
||||||
if self.modifiers.shift {
|
if self.modifiers.shift {
|
||||||
f.write_char('⇧')?;
|
if cfg!(target_os = "macos") {
|
||||||
|
f.write_char('⇧')?;
|
||||||
|
} else {
|
||||||
|
write!(f, "shift-")?;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
let key = match self.key.as_str() {
|
let key = match self.key.as_str() {
|
||||||
"backspace" => '⌫',
|
"backspace" if cfg!(target_os = "macos") => '⌫',
|
||||||
"up" => '↑',
|
"up" if cfg!(target_os = "macos") => '↑',
|
||||||
"down" => '↓',
|
"down" if cfg!(target_os = "macos") => '↓',
|
||||||
"left" => '←',
|
"left" if cfg!(target_os = "macos") => '←',
|
||||||
"right" => '→',
|
"right" if cfg!(target_os = "macos") => '→',
|
||||||
"tab" => '⇥',
|
"tab" if cfg!(target_os = "macos") => '⇥',
|
||||||
"escape" => '⎋',
|
"escape" if cfg!(target_os = "macos") => '⎋',
|
||||||
"shift" => '⇧',
|
"shift" if cfg!(target_os = "macos") => '⇧',
|
||||||
"control" => '⌃',
|
"control" if cfg!(target_os = "macos") => '⌃',
|
||||||
"alt" => '⌥',
|
"alt" if cfg!(target_os = "macos") => '⌥',
|
||||||
"platform" => '⌘',
|
"platform" if cfg!(target_os = "macos") => '⌘',
|
||||||
key => {
|
key => {
|
||||||
if key.len() == 1 {
|
if key.len() == 1 {
|
||||||
key.chars().next().unwrap().to_ascii_uppercase()
|
key.chars().next().unwrap().to_ascii_uppercase()
|
||||||
|
|
|
@ -378,12 +378,7 @@ pub fn text_for_keystroke(keystroke: &Keystroke, cx: &App) -> String {
|
||||||
/// Returns a textual representation of the given [`Keystroke`].
|
/// Returns a textual representation of the given [`Keystroke`].
|
||||||
fn keystroke_text(keystroke: &Keystroke, platform_style: PlatformStyle, vim_mode: bool) -> String {
|
fn keystroke_text(keystroke: &Keystroke, platform_style: PlatformStyle, vim_mode: bool) -> String {
|
||||||
let mut text = String::new();
|
let mut text = String::new();
|
||||||
|
let delimiter = '-';
|
||||||
let delimiter = match (platform_style, vim_mode) {
|
|
||||||
(PlatformStyle::Mac, false) => '-',
|
|
||||||
(PlatformStyle::Linux | PlatformStyle::Windows, false) => '-',
|
|
||||||
(_, true) => '-',
|
|
||||||
};
|
|
||||||
|
|
||||||
if keystroke.modifiers.function {
|
if keystroke.modifiers.function {
|
||||||
match vim_mode {
|
match vim_mode {
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue