Skip to content

Commit

Permalink
Ignore keypresses during IME composition (lite-xl#1573)
Browse files Browse the repository at this point in the history
Some IMEs continue sending keypresses even during composition, so we 
just ignore them.
  • Loading branch information
Guldoman authored and takase1121 committed Oct 18, 2023
1 parent a066190 commit 8c45192
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 4 deletions.
3 changes: 3 additions & 0 deletions data/core/init.lua
Original file line number Diff line number Diff line change
Expand Up @@ -1243,6 +1243,9 @@ function core.on_event(type, ...)
elseif type == "textediting" then
ime.on_text_editing(...)
elseif type == "keypressed" then
-- In some cases during IME composition input is still sent to us
-- so we just ignore it.
if ime.editing then return false end
did_keymap = keymap.on_key_pressed(...)
elseif type == "keyreleased" then
keymap.on_key_released(...)
Expand Down
4 changes: 0 additions & 4 deletions data/core/keymap.lua
Original file line number Diff line number Diff line change
Expand Up @@ -203,10 +203,6 @@ end
-- Events listening
--------------------------------------------------------------------------------
function keymap.on_key_pressed(k, ...)
-- In MacOS and Windows during IME composition input is still sent to us
-- so we just ignore it
if PLATFORM ~= "Linux" and ime.editing then return false end

local mk = modkey_map[k]
if mk then
keymap.modkeys[mk] = true
Expand Down

0 comments on commit 8c45192

Please sign in to comment.