You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
[Bug] Japanese IME input breaks when typing immediately after a code fence #4851
When typing Japanese text with an IME immediately after a code fence, the input becomes broken after the first character.
This seems to happen when I start typing Japanese text right after creating a code fence with three backticks and moving to the next input position.
Steps to Reproduce
Make sure Source Code Mode is disabled.
Open MarkText 0.20.0-beta.5.
Create a new document.
Type three backticks to create a code fence.
Press Enter or move the cursor immediately after the code fence.
Try typing Japanese text using a Japanese IME.
For example, try typing "てすと".
Expected Behavior
Japanese text should be entered normally.
For example, when typing "てすと", it should appear as "てすと" without any broken or unexpected characters.
Actual Behavior
The first character is entered correctly, but the second character becomes broken or unexpected.
For example, when I try to type Japanese text, the result may become "nあ" or "kあ" instead of the expected input.
After that, the third and later characters can usually be typed normally.
In another test with repeated input, the result became something like "かkあかかかかかかかかか".
This issue reliably happens when Source Code Mode is disabled.
I could not reproduce it when Source Code Mode was enabled.
When Typewriter Mode is enabled, the behavior becomes less consistent: sometimes the issue happens on the first character, and sometimes it does not happen.
Reproduced this on 0.20.0-beta.5, and confirmed it is fixed from v0.20.0-rc.2 onwards.
What was happening
A code block whose text ends in a newline used to render that newline inside its own <span class="mu-line-end">. With the caret at the end of the block it therefore sat inside the newline's own text node — and Chromium will not sustain an IME composition there. It overwrites the newline and abandons the composition, so the input method loses the first keystroke of the word. That is where the leftover half-width romaji next to the kana came from (nあ, kあ, かkあかかか…).
Driving a real Chromium composition through CDP Input.imeSetComposition against the beta.5 source — caret at the end of a code block containing abc\n, then typing てすと:
version
result
0.20.0-beta.5
abctてすと — the newline is eaten and a stray t leaks in as plain text
0.20.0-rc.2+
abc + newline + てすと — correct
The fix
#5286 (19faab16) moved the trailing newline back into the block's main text node and gave the empty last line its line box with a <span class="mu-trailing-break"><br></span> instead. The caret no longer lands inside the newline's own node, so the composition is never interrupted. That change first shipped in v0.20.0-rc.2.
It was released as a fix for #5114 (caret on a code block's empty last line), so this issue was never linked to it — hence closing it only now.
Closing as fixed. @rain2542 if you still see this on rc.5 or later, please reopen with the version you tested.
Activity
fix(muya): stop editor handlers from fighting IME composition
fix(muya): stop editor handlers from fighting IME composition
fix(muya): stop rebuilding a code block's DOM when the render is unch…
test(muya): pin code-block render idempotence and IME node identity (#…
Jocs commentedon Sep 22, 2026
Reproduced this on 0.20.0-beta.5, and confirmed it is fixed from v0.20.0-rc.2 onwards.
What was happening
A code block whose text ends in a newline used to render that newline inside its own
<span class="mu-line-end">. With the caret at the end of the block it therefore sat inside the newline's own text node — and Chromium will not sustain an IME composition there. It overwrites the newline and abandons the composition, so the input method loses the first keystroke of the word. That is where the leftover half-width romaji next to the kana came from (nあ,kあ,かkあかかか…).Driving a real Chromium composition through CDP
Input.imeSetCompositionagainst the beta.5 source — caret at the end of a code block containingabc\n, then typing てすと:abctてすと— the newline is eaten and a straytleaks in as plain textabc+ newline +てすと— correctThe fix
#5286 (
19faab16) moved the trailing newline back into the block's main text node and gave the empty last line its line box with a<span class="mu-trailing-break"><br></span>instead. The caret no longer lands inside the newline's own node, so the composition is never interrupted. That change first shipped in v0.20.0-rc.2.It was released as a fix for #5114 (caret on a code block's empty last line), so this issue was never linked to it — hence closing it only now.
Closing as fixed. @rain2542 if you still see this on rc.5 or later, please reopen with the version you tested.