fix: iOS Safari Chinese punctuation input not working #5614
+28
−5
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.
Summary
Fix Chinese punctuation input (,。!?) and emoji not working correctly on iOS Safari.
Problem
Chinese Punctuation
On iOS Safari, Chinese punctuation and spaces are dropped when using IME input. The input events have
ev.composed=truebut don't go through the composition flow (nocompositionstart/compositionendevents).The existing condition
(!ev.composed || !this._keyDownSeen)rejects these inputs because:ev.composedistrue(crossed shadow DOM boundary)_keyDownSeenistrue(keydown fired before input)Emoji Duplication
On iOS Safari, emoji input causes duplicates because of timing:
compositionendfires →isComposingbecomesfalseinputevent fires → xterm.js would accept it (first copy)setTimeoutin CompositionHelper fires → sends emoji (second copy)Solution
Replace the condition with two checks:
!compositionHelper.isComposing- not actively composing!compositionHelper.isSendingComposition- no pending setTimeout to send compositionAdded public getter
isSendingCompositionto CompositionHelper to expose the_isSendingCompositionstate.This correctly handles all cases:
Changes
src/browser/input/CompositionHelper.ts: AddedisSendingCompositiongettersrc/browser/Types.ts: AddedisSendingCompositiontoICompositionHelperinterfacesrc/browser/CoreBrowserTerminal.ts: Updated condition in_inputEvent()Testing
Tested on iOS Safari with:
Related Issues
Fixes #3070
Fixes #4486