wayland: Fix input_handler out of range access (#10724)

The wayland implementation takes an input handler from the state, but
only puts it back if the event was an IME key. I flipped the logic to
ensure it's always put back.

This should fix both:
- #10344
- #10652

Release Notes:

- Fixed input_handler out of range access
([#10344](https://github.com/zed-industries/zed/issues/10344),
[#10652](https://github.com/zed-industries/zed/issues/10652)).
This commit is contained in:
Philipp Schaffrath 2024-04-19 00:20:23 +02:00 committed by GitHub
parent b31df39ab0
commit 15c4c4a308
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -481,13 +481,12 @@ impl WaylandWindowStatePtr {
}
}
if let PlatformInput::KeyDown(event) = input {
let mut state = self.state.borrow_mut();
if let Some(mut input_handler) = state.input_handler.take() {
if let Some(ime_key) = &event.keystroke.ime_key {
if let Some(ime_key) = &event.keystroke.ime_key {
let mut state = self.state.borrow_mut();
if let Some(mut input_handler) = state.input_handler.take() {
drop(state);
input_handler.replace_text_in_range(None, ime_key);
let mut state = self.state.borrow_mut();
state.input_handler = Some(input_handler);
self.state.borrow_mut().input_handler = Some(input_handler);
}
}
}