fix(insertion-windows): route per-codepoint Unicode SendInput through clipboard#363
fix(insertion-windows): route per-codepoint Unicode SendInput through clipboard#363katanumahotori wants to merge 2 commits intoOpen-Less:betafrom
Conversation
… clipboard insert_via_unicode_keystrokes was injecting one KEYEVENTF_UNICODE SendInput per codepoint. On a Japanese host this competes with the active IME's composition state - hiragana ends up queued in the IME composition window while kanji / ascii get inserted ahead of it, so the user sees text reordered with kanji pushed to the end. Route this path through the existing clipboard+Ctrl+V fallback so IME doesn't intercept individual codepoints. Also force the return value to InsertStatus::Inserted so coordinator.rs's gating logic doesn't double-paste via the non-TSF fallback path. Splits simulate_paste into per-OS impls so the keystroke synth is isolated to Linux (enigo Ctrl+V), and Windows uses the same enigo path which is fine because Ctrl+V as a *keyboard shortcut* is not intercepted by IME composition (only KEYEVENTF_UNICODE is).
|
Codex usage limits have been reached for code reviews. Please check with the admins of this repo to increase the limits by adding credits. |
PR Reviewer Guide 🔍(Review updated until commit 5805e20)Here are some key observations to aid the review process:
|
|
不符合要求: 通过短路 prepare_session() 函数,强制跳过非 zh 主机上的 TSF。 |
…f clipboard fallback
|
Re: the previous comment — I think a copy was pasted from PR #362. Treating this PR on its own merits: The original PR re-routed Implementation:
So callers see the same behavior on zh / en hosts (Unicode SendInput goes through), but on Japanese hosts ATOK / Microsoft IME no longer reorders the kanji. Please re-review. |
|
Persistent review updated to latest commit 5805e20 |
…llback PR Open-Less#360 made TextInserter::insert require a 3rd PasteShortcut arg. The fork-only insert_via_unicode_keystrokes (PR Open-Less#363, ATOK kanji-pushout clipboard fallback) calls insert(text, true) — needed updating for the new signature. Hardcoded CtrlV here because the clipboard fallback is specifically engineered around Ctrl+V semantics on ATOK hosts; user's configured paste_shortcut applies to the regular paste path.
User description
Why
insert_via_unicode_keystrokeswas injecting oneKEYEVENTF_UNICODESendInputper codepoint. On a Japanese host this competes with the active IME's composition state - hiragana ends up queued in the IME composition window while kanji / ascii get inserted ahead of it, so the user sees text reordered with kanji pushed to the end.What
InsertStatus::Insertedsocoordinator.rs's gating logic doesn't double-paste via the non-TSF fallback path.simulate_pasteinto per-OS impls so the keystroke synth is isolated to Linux (enigo Ctrl+V). Windows uses the same enigo path which is fine because Ctrl+V as a keyboard shortcut is not intercepted by IME composition (onlyKEYEVENTF_UNICODEis).Note
Companion to #362 (force-skip TSF on non-zh hosts). Either PR alone helps; both together fully eliminate the Japanese-host text reorder bug.
PR Type
Bug fix
Description
Add
send_text_with_ime_detached()to temporarily detach IME context during Unicode SendInput, preventing text reordering by Japanese IMEsModify
insert_via_unicode_keystrokesto use the IME‑detached path and fall back to clipboard paste on failureUpdate
simulate_pastecomment clarifying that Ctrl+V does not compete with IMEAdd
Win32_UI_Input_Imefeature dependency for IME context managementDiagram Walkthrough
File Walkthrough
insertion.rs
IME-detached Unicode keystrokes to fix text reorderingopenless-all/app/src-tauri/src/insertion.rs
send_text_with_ime_detached()to temporarily detach and restoreIME context
insert_via_unicode_keystrokesto use the new function andfallback to clipboard on error
simulate_pastesend_text()with#[allow(dead_code)]Cargo.toml
Add IME feature dependency for Windowsopenless-all/app/src-tauri/Cargo.toml
Win32_UI_Input_Imefeature to enable IME context API usage