Fix IME input when composing in the middle of the textarea#5698
Merged
Tyriar merged 3 commits intoxtermjs:masterfrom Mar 11, 2026
Merged
Fix IME input when composing in the middle of the textarea#5698Tyriar merged 3 commits intoxtermjs:masterfrom
Tyriar merged 3 commits intoxtermjs:masterfrom
Conversation
Track the composition range using the textarea selection and avoid re-sending trailing text that existed before composition started (notably in screenReaderMode). Fixes xtermjs#5456
Closed
Member
Tyriar
approved these changes
Mar 11, 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.


Fixes #5456
When
screenReaderModeis enabled, moving the caret inside existing text and then committing IME input can cause stale trailing text from the textarea's previous state to be re-sent.This PR fixes composition range tracking in two places:
compositionstart, it usestextarea.selectionStart/selectionEnd(the actual caret/selection) instead oftextarea.value.length.compositionendwhile avoiding re-sending trailing text that already existed before composition started.This keeps composition diffing aligned with the real insertion point and prevents stale suffix insertion.
Repro
screenReaderMode.一二via IME.一and二.一via IME.一二二(the previous trailing二is re-sent).
一一二.Validation
screenReaderMode: truebefore the fix; no repro after the fix.screenReaderMode: false).Related VS Code issues: