Fix ci" on a brazillian keyboard (#13185)
Some checks are pending
CI / Check formatting and spelling (push) Waiting to run
CI / (macOS) Run Clippy and tests (push) Waiting to run
CI / (Linux) Run Clippy and tests (push) Waiting to run
CI / (Windows) Run Clippy and tests (push) Waiting to run
CI / Create a macOS bundle (push) Blocked by required conditions
CI / Create a Linux bundle (push) Blocked by required conditions
CI / Create arm64 Linux bundle (push) Blocked by required conditions
Deploy Docs / Deploy Docs (push) Waiting to run

Fixes: #12523

Release Notes:

- vim: Fix ci" on keyboards where typing a " requires the IME (#12523)
This commit is contained in:
Conrad Irwin 2024-06-17 22:38:36 -06:00 committed by GitHub
parent 05c4c7872c
commit 51404d4ea0
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 22 additions and 4 deletions

View file

@ -109,6 +109,17 @@ impl Keystroke {
}) })
} }
/// Returns true if this keystroke left
/// the ime system in an incomplete state.
pub fn is_ime_in_progress(&self) -> bool {
self.ime_key.is_none()
&& (is_printable_key(&self.key) || self.key.is_empty())
&& !(self.modifiers.platform
|| self.modifiers.control
|| self.modifiers.function
|| self.modifiers.alt)
}
/// Returns a new keystroke with the ime_key filled. /// Returns a new keystroke with the ime_key filled.
/// This is used for dispatch_keystroke where we want users to /// This is used for dispatch_keystroke where we want users to
/// be able to simulate typing "space", etc. /// be able to simulate typing "space", etc.
@ -123,9 +134,7 @@ impl Keystroke {
"space" => Some(" ".into()), "space" => Some(" ".into()),
"tab" => Some("\t".into()), "tab" => Some("\t".into()),
"enter" => Some("\n".into()), "enter" => Some("\n".into()),
"up" | "down" | "left" | "right" | "pageup" | "pagedown" | "home" | "end" key if !is_printable_key(key) => None,
| "delete" | "escape" | "backspace" | "f1" | "f2" | "f3" | "f4" | "f5" | "f6"
| "f7" | "f8" | "f9" | "f10" | "f11" | "f12" => None,
key => { key => {
if self.modifiers.shift { if self.modifiers.shift {
Some(key.to_uppercase()) Some(key.to_uppercase())
@ -139,6 +148,15 @@ impl Keystroke {
} }
} }
fn is_printable_key(key: &str) -> bool {
match key {
"up" | "down" | "left" | "right" | "pageup" | "pagedown" | "home" | "end" | "delete"
| "escape" | "backspace" | "f1" | "f2" | "f3" | "f4" | "f5" | "f6" | "f7" | "f8" | "f9"
| "f10" | "f11" | "f12" => false,
_ => true,
}
}
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 {

View file

@ -187,7 +187,7 @@ fn observe_keystrokes(keystroke_event: &KeystrokeEvent, cx: &mut WindowContext)
if action.name().starts_with("vim::") { if action.name().starts_with("vim::") {
return; return;
} }
} else if cx.has_pending_keystrokes() { } else if cx.has_pending_keystrokes() || keystroke_event.keystroke.is_ime_in_progress() {
return; return;
} }