Repository navigation
fix(muya): preserve cursor on IME composition backspace(#4956) - #4957
Merged
Merged
Conversation
Contributor
Author
|
@Jocs Hi, do you have time to take a look at the current bug fix? I'd really like to contribute. |
niyo-oyin
added a commit
to niyo-oyin/marktext-ja
that referenced
this pull request
Jul 29, 2026
Four fixes, all the same failure class — editor code acting on keys or input events that belong to an open IME composition: - content.ts keydownHandler: guard Backspace/Delete with !isComposed, matching the existing Enter/arrows/Tab guards. Mid-composition they ran backspaceHandler/deleteHandler against a stale text snapshot and dislocated the cursor (upstream marktext#4956; reimplements PR marktext#4957). - codeBlockContent: apply upstream PR marktext#4876 (Jocs) verbatim — an IME commit no longer rebuilds domNode.innerHTML synchronously (which destroyed the text node the IME was anchored to, corrupting Japanese input from the 2nd character, marktext#4851); the syntax re-highlight runs behind a 300ms trailing debounce instead. State updates stay synchronous; structural edits still rebuild synchronously. - langInputContent: the code-fence language input had no composition handling at all — every mid-composition input event rebuilt innerHTML. Ignore inputs while composing and commit IME text without re-rendering, same mechanism as marktext#4876. - Float tools: handleContentKeydown, the BaseScrollFloat nav handler and the BaseFloat Escape handler now ignore keys pressed while a composition is open — Enter/Escape/Tab/arrows operate the IME's candidate list, not the float. All fixes are unit-tested with synthetic composition events; each new spec fails on the pre-fix code. Muya suite 1454/1454, lint/tsc/madge clean. Co-Authored-By: Claude Fable 5 <[email protected]> Claude-Session: https://claude.ai/code/session_01Ef4yFuXFbyKNTazkwUtygY
niyo-oyin
added a commit
to niyo-oyin/marktext-ja
that referenced
this pull request
Jul 29, 2026
Four fixes, all the same failure class — editor code acting on keys or input events that belong to an open IME composition: - content.ts keydownHandler: guard Backspace/Delete with !isComposed, matching the existing Enter/arrows/Tab guards. Mid-composition they ran backspaceHandler/deleteHandler against a stale text snapshot and dislocated the cursor (upstream marktext#4956; reimplements PR marktext#4957). - codeBlockContent: apply upstream PR marktext#4876 (Jocs) verbatim — an IME commit no longer rebuilds domNode.innerHTML synchronously (which destroyed the text node the IME was anchored to, corrupting Japanese input from the 2nd character, marktext#4851); the syntax re-highlight runs behind a 300ms trailing debounce instead. State updates stay synchronous; structural edits still rebuild synchronously. - langInputContent: the code-fence language input had no composition handling at all — every mid-composition input event rebuilt innerHTML. Ignore inputs while composing and commit IME text without re-rendering, same mechanism as marktext#4876. - Float tools: handleContentKeydown, the BaseScrollFloat nav handler and the BaseFloat Escape handler now ignore keys pressed while a composition is open — Enter/Escape/Tab/arrows operate the IME's candidate list, not the float. All fixes are unit-tested with synthetic composition events; each new spec fails on the pre-fix code. Muya suite 1454/1454, lint/tsc/madge clean.
Member
|
Apologies for the delayed review, I was away on summer vacation. Thanks for your contribution! |
Jocs
approved these changes
Sep 3, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #4956
Summary
Why: During IME composition, Backspace/Delete triggered the editor's backspaceHandler/deleteHandler instead of the IME. Since composition text isn't in this.text yet, the handler ran on a stale snapshot, dislocating the cursor.
Fix: Added if (!this.isComposed) guard in keydownHandler for Backspace/Delete, matching the existing guard for Enter/arrows/Tab.
Changes:
content.ts: guard the two keys during composition.
imeBackspaceComposition.spec.ts: new test (4 cases) covering composing vs. non-composing Backspace/Delete.
Type of change
Test plan
Notes for reviewers [optional]
By submitting this pull request, I confirm that my contribution is made under the terms of the MIT license.