From 393b16d2262d6bf94ea0ea9c982ab2b1c2736fae Mon Sep 17 00:00:00 2001 From: Jakob Hellermann Date: Fri, 26 Apr 2024 23:07:05 +0200 Subject: [PATCH] Fix Wayland keyrepeat getting cancelled by unrelated keyup (#11052) fixes #11048 ## Problem in the situation `press right`, `press left`, `release right` the following happens right now: - `keypressed right`, `current_keysym` is set to `right` - `keypressed left`, `current_keysym` is set to `left` the repeat timer runs asynchronously and emits keyrepeats since `current_keysym.is_some()` - `keyreleased right`, `current_keysym` is set to None the repeat timer no longer emits keyrepeats - `keyreleased left`, this is where `current_keysym` should actually be set to None. ## Solution Only reset `current_keysym` if the released key matches the last pressed key. Release Notes: - N/A --- crates/gpui/src/platform/linux/wayland/client.rs | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/crates/gpui/src/platform/linux/wayland/client.rs b/crates/gpui/src/platform/linux/wayland/client.rs index 8f23b2292153e85a0a2432da4a621eda4d851eba..698134bcbc919c91ff5b18c06abb75cd434dda5c 100644 --- a/crates/gpui/src/platform/linux/wayland/client.rs +++ b/crates/gpui/src/platform/linux/wayland/client.rs @@ -843,7 +843,9 @@ impl Dispatch for WaylandClientStatePtr { keystroke: Keystroke::from_xkb(keymap_state, state.modifiers, keycode), }); - state.repeat.current_keysym = None; + if state.repeat.current_keysym == Some(keysym) { + state.repeat.current_keysym = None; + } drop(state); focused_window.handle_input(input);