[PR #4796] Make Korean IME input more consistent #25951

Closed
opened 2026-01-31 09:12:52 +00:00 by claunia · 0 comments
Owner

Original Pull Request: https://github.com/microsoft/terminal/pull/4796

State: closed
Merged: Yes


Summary of the Pull Request

Korean IME was not working correctly due to way we were clearing the input buffer inside of TSFInputControl. We wanted to clear our input buffer and tell TSF to clear its input buffer as well when we receive a CompositionCompleted event. This works fine in some IME languages such as Chinese and Japanese. However, Korean IME composes characters differently in such a way where we can't tell TSF to clear their buffer during a CompositionCompleted event because it would clear the character that triggered the CompositionCompleted event in the first place.

The solution in this PR is to keep our _inputBuffer intact until the user presses Enter or Esc, in which case we clear our buffer and the TSF buffer. I've chosen these two keys because it seems to make sense to clear the buffer after text is sent to the terminal with Enter, and Esc usually means to cancel a current composition anyway.

This means we need to keep track of our last known "Composition Start Point", which is represented by _activeTextStart. Whenever we complete a composition, we'll send the portion of the input buffer between _activeTextStart and the end of the input buffer to the terminal. Then, we'll update _activeTextStart to be the end of the input buffer so that the next time we send text to the terminal, we'll only send the portion of our buffer that's "active".

PR Checklist

Validation Steps Performed

Manual testing with Chinese, Japanese, and Korean IME.

**Original Pull Request:** https://github.com/microsoft/terminal/pull/4796 **State:** closed **Merged:** Yes --- ## Summary of the Pull Request Korean IME was not working correctly due to way we were clearing the input buffer inside of `TSFInputControl`. We wanted to clear our input buffer and tell TSF to clear its input buffer as well when we receive a `CompositionCompleted` event. This works fine in some IME languages such as Chinese and Japanese. However, Korean IME composes characters differently in such a way where we can't tell TSF to clear their buffer during a `CompositionCompleted` event because it would clear the character that triggered the `CompositionCompleted` event in the first place. The solution in this PR is to keep our `_inputBuffer` intact until the user presses <kbd>Enter</kbd> or <kbd>Esc</kbd>, in which case we clear our buffer and the TSF buffer. I've chosen these two keys because it seems to make sense to clear the buffer after text is sent to the terminal with <kbd>Enter</kbd>, and <kbd>Esc</kbd> usually means to cancel a current composition anyway. This means we need to keep track of our last known "Composition Start Point", which is represented by `_activeTextStart`. Whenever we complete a composition, we'll send the portion of the input buffer between `_activeTextStart` and the end of the input buffer to the terminal. Then, we'll update `_activeTextStart` to be the end of the input buffer so that the next time we send text to the terminal, we'll only send the portion of our buffer that's "active". ## PR Checklist * [x] Closes #4226 * [x] CLA signed * [x] Tests added/passed ## Validation Steps Performed Manual testing with Chinese, Japanese, and Korean IME.
claunia added the pull-request label 2026-01-31 09:12:52 +00:00
Sign in to join this conversation.
No Label pull-request
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/terminal#25951