Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: Fix deadkey sequences ending with space #1930

Merged
merged 2 commits into from
Jul 31, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
17 changes: 13 additions & 4 deletions src/window/keyboard_manager.rs
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ impl KeyboardManager {
}

fn format_key(&self, key_event: &KeyEvent) -> Option<String> {
if let Some(text) = get_special_key(&key_event.logical_key) {
if let Some(text) = get_special_key(key_event) {
Some(self.format_key_text(text, true))
} else {
self.format_normal_key(key_event)
Expand Down Expand Up @@ -98,7 +98,7 @@ impl KeyboardManager {

fn format_key_text(&self, text: &str, is_special: bool) -> String {
let modifiers = self.format_modifier_string(is_special);
// < needs to be formatted as a special character, but note that it's not threated as a
// < needs to be formatted as a special character, but note that it's not treated as a
// special key for the modifier formatting, so S- and -M are still potentially stripped
let (text, is_special) = if text == "<" {
("lt", true)
Expand Down Expand Up @@ -154,10 +154,19 @@ fn use_alt() -> bool {
settings.macos_alt_is_meta
}

fn get_special_key(key: &Key) -> Option<&str> {
fn get_special_key(key_event: &KeyEvent) -> Option<&str> {
let key = &key_event.logical_key;
match key {
Key::Backspace => Some("BS"),
Key::Space => Some("Space"),
Key::Space => {
// Space can finish a dead key sequence, so treat space as a special key only when
// that doesn't happen.
if key_event.text == Some(" ".into()) {
Some("Space")
} else {
None
}
}
Key::Escape => Some("Esc"),
Key::Delete => Some("Del"),
Key::ArrowUp => Some("Up"),
Expand Down