Fix Korean IME overlay hiding characters to the right of cursor#20041
Merged
DHowett merged 5 commits intomicrosoft:mainfrom Apr 17, 2026
Merged
Conversation
…cursor When composing a new character between two existing characters, the in-progress composition text was drawn over the character immediately to the right of the cursor, visually hiding it during composition. This happened because the tsfPreview overlay used an overwrite-style render, writing the composition text at the cursor column without preserving the displaced content. The fix copies the original characters from that position back into the visual row at the position just after the composition text ends, changing the appearance from overwrite to insert. The buffer itself is not modified; the change is local to the temporary row modification that is restored after each paint frame. This regression was introduced by commit a3d508a (Remove TF_TMAE_UIELEMENTENABLEDONLY, microsoft#19738), which caused the Korean IME to switch from IMM32 (which renders its own floating composition window) to TSF (which uses the terminal's inline tsfPreview rendering), exposing this rendering flaw.
Reverts the change that shifted existing characters to the right of the cursor when rendering an in-progress TSF composition (tsfPreview). The approach was an unconditional rightward shift of all content from the cursor position, which caused box-drawing characters in TUI applications to be displaced and rendered at wrong positions or cut off entirely. Example of the breakage in a TUI text box: Before (correct): |Hello [ㄷ] | After (broken): |Hello [ㄷ]Worl|d (border shifted off screen) The correct fix requires consuming an equal amount of whitespace to the right of the composition before shifting, so that box borders remain at their original column positions when trailing whitespace is available. This improved approach will be implemented separately as Fix 2-1. Reviewer feedback: When you're in a TUI application, there may be a box around the text field. Shifting text from the cursor to the right means that the right border (and anything else in the TUI app) also shifts to the right. One solution for this is that we try to remove an equal amount of whitespace to the right of the composition.
…cursor When composing a new Korean character between existing text, the in-progress composition overlay was drawn using an overwrite-style render that hid any character immediately to the right of the cursor. This is visually incorrect for Korean IME, which inserts rather than replaces. The fix copies original characters from the cursor position back to the right of the composition text, using a whitespace-absorption algorithm so that TUI box borders stay at their original column positions when trailing whitespace is available. Up to W whitespace columns (where W is the composition width) are consumed silently; remaining non-whitespace content is shifted rightward. If no whitespace is available, the shift is unavoidable (border may move), but this is the best achievable behavior for fixed-width lines. The rendering change is purely visual: the buffer row is restored in full after each paint frame by the existing wil::scope_exit restore mechanism. This approach was suggested by a reviewer as a refinement to a prior attempt that shifted all content unconditionally and broke TUI box borders. Closes microsoft#20040
Member
|
/azp run |
|
Azure Pipelines successfully started running 1 pipeline(s). |
lhecker
reviewed
Mar 31, 2026
Member
There was a problem hiding this comment.
The compositionRow code is now rather lengthy with this new code. I think it makes sense to hoist it into its own dedicated function if possible. But the changes overall look good to me. 🙂
Let me think about this over the next few days! I'll check this PR out locally.
lhecker
reviewed
Apr 16, 2026
| } | ||
|
|
||
| compositionEnd = state.columnEnd; | ||
| } |
Member
There was a problem hiding this comment.
The block above is identical to before.
DHowett
approved these changes
Apr 16, 2026
auto-merge was automatically disabled
April 16, 2026 23:43
Pull request was closed
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.


This commit fixes a regression in v1.24, where composing Korean text
in-between existing characters causes text to the right to be hidden.
This is problematic for the Korean IME, because it commonly inserts
the composed syllable between existing characters.
The fix compresses (removes/absorbs) available whitespace to the right
of the composition to make space for any existing text. This means
that a composition now virtually acts in insert mode.
Closes #20040
Refs #19738
Refs #20039
Validation Steps Performed
ㄷbetween가and나→ display shows가ㄷ나,나visible.Co-authored-by: Leonard Hecker lhecker@microsoft.com