Skip to content

Commit

Permalink
On macOS, fix backspace emission on preedit clear
Browse files Browse the repository at this point in the history
Fixes: d15feb5 (On macOS, fix empty marked text)
  • Loading branch information
kchibisov committed May 14, 2023
1 parent 5278441 commit 8e4ef92
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 2 deletions.
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,9 @@ And please only add new entries to the top of this list, right below the `# Unre

# Unreleased

- On macOS, fixed memory leak when getting monitor handle.
- On macOS, fix `Backspace` being emitted when clearing preedit with it.

# 0.28.5

- On macOS, fix `key_up` beind ignored when `Ime` is disabled.
Expand Down
6 changes: 4 additions & 2 deletions src/platform_impl/macos/view.rs
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ impl Default for CursorState {
}
}

#[derive(Debug, Eq, PartialEq)]
#[derive(Debug, Eq, PartialEq, Clone, Copy)]
enum ImeState {
/// The IME events are disabled, so only `ReceivedCharacter` is being sent to the user.
Disabled,
Expand Down Expand Up @@ -481,6 +481,7 @@ declare_class!(
&& !ev_mods.logo();

let characters = get_characters(event, ignore_alt_characters);
let old_ime_state = self.state.ime_state;
self.state.forward_key_to_app = false;

// The `interpretKeyEvents` function might call
Expand Down Expand Up @@ -518,7 +519,8 @@ declare_class!(
true
}
ImeState::Preedit => true,
_ => false,
// `key_down` could result in preedit clear, so compare old and current state.
_ => old_ime_state != self.state.ime_state,
};

if !had_ime_input || self.state.forward_key_to_app {
Expand Down

0 comments on commit 8e4ef92

Please sign in to comment.