Skip to content

Commit

Permalink
fix: Fix deadkey sequences ending with space
Browse files Browse the repository at this point in the history
A dead key followed by space will usually result in the character
itself. However, Neovide resolved this wrongly, and always treated
space as a special key, so the sequence was resolved as space instead.
  • Loading branch information
fredizzimo committed Jul 9, 2023
1 parent 372f29b commit 2afcd2d
Showing 1 changed file with 12 additions and 3 deletions.
15 changes: 12 additions & 3 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) {

Check warning on line 70 in src/window/keyboard_manager.rs

View workflow job for this annotation

GitHub Actions / clippy

[clippy] reported by reviewdog 🐶 <pre><code>warning: this expression creates a reference which is immediately dereferenced by the compiler --> src/window/keyboard_manager.rs:70:45 | 70 | if let Some(text) = get_special_key(&key_event) { | ^^^^^^^^^^ help: change this to: `key_event` | = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#needless_borrow = note: `#[warn(clippy::needless_borrow)]` on by default </code></pre> Raw Output: src/window/keyboard_manager.rs:70:45:w: <pre><code>warning: this expression creates a reference which is immediately dereferenced by the compiler --> src/window/keyboard_manager.rs:70:45 | 70 | if let Some(text) = get_special_key(&key_event) { | ^^^^^^^^^^ help: change this to: `key_event` | = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#needless_borrow = note: `#[warn(clippy::needless_borrow)]` on by default </code></pre> __END__
Some(self.format_key_text(text, true))
} else {
self.format_normal_key(key_event)
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 only threat space as a special key 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

0 comments on commit 2afcd2d

Please sign in to comment.