Skip to content

fix: do not panic when the window cannot provide an IME - #1088

Open
criccomini wants to merge 1 commit into
lapce:mainfrom
criccomini:headless-ime
Open

criccomini wants to merge 1 commit into
lapce:mainfrom
criccomini:headless-ime

Conversation

@criccomini

Copy link
Copy Markdown
Contributor

Focusing a view that allows IME — a text input, or the editor — sends SetImeAllowed, and WindowHandle unwrapped the window's answer:

self.window.request_ime_update(ime).unwrap();

The headless MockWindow refuses every IME request with ImeRequestError::NotSupported, so any HeadlessHarness test that clicked into a text input panicked at src/window/handle.rs:1270. A platform without an IME would take the app down the same way.

This routes the enable, disable and cursor-area requests through one helper that drops the refusal: the view still takes focus and works, it just gets no composition input. A new headless test (tests/headless_ime.rs) clicks into a TextInput, which panics before this change and passes after it.

Found while writing headless tests for an editor-based app: every test that pressed the editor hit this.

🤖 Generated with Claude Code

Focusing a view that allows IME, such as a text input or the editor,
sends SetImeAllowed, and the handler unwrapped the window's answer. The
headless mock window refuses every IME request with NotSupported, so any
headless test that focused a text input panicked; a platform without an
IME would bring the app down the same way.

Route the enable, disable and cursor-area requests through one helper
that drops the refusal: the view still takes focus and works, it just
gets no composition input. A headless test clicks into a text input to
keep it that way.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
criccomini added a commit to criccomini/floem that referenced this pull request Sep 21, 2026
Alt with an arrow is a word movement in a text box, and it is also the
key floem's default action walks the focus with: after the handlers,
`handle_default_behaviors` sends the focus to the nearest keyboard-
navigable neighbour in the arrow's direction unless one of them prevented
the default. The editor moved its cursor by the word and let the default
run, so the focus left for a button beside it and the next keystroke went
there. The text input did the same, and at the front of its buffer, with
no word to move to, it reported the key unhandled as well.

The editor now prevents the default for any key it ran a command for, as
it already did for Tab: a key it has a command for is its own. The text
input prevents it for an arrow whether or not the cursor could move by
it, the way a native field never gives up the keyboard on one.

The test gives a box the keyboard headlessly, which needs the mock window
to take a refused IME request (lapce#1088).

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
(cherry picked from commit 4d92f6a5bec9c3023cde8982a3521627ede53fb9)

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant