[PR #4796] [MERGED] Make Korean IME input more consistent #25946

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

📋 Pull Request Information

Original PR: https://github.com/microsoft/terminal/pull/4796
Author: @leonMSFT
Created: 3/4/2020
Status: Merged
Merged: 3/4/2020
Merged by: @undefined

Base: masterHead: dev/lelian/koreaninput


📝 Commits (10+)

  • cd8bc7c korean input seems to work, but now emojis don't work :sadface:
  • 646ed57 merge conflicts
  • e98d6d4 LOOKIN GUD
  • a36f8bb Merge branch 'master' into dev/lelian/koreaninput
  • b194b40 Merge branch 'master' into dev/lelian/koreaninput
  • d178336 Merge branch 'master' into dev/lelian/koreaninput
  • 7fe9aab Merge branch 'master' into dev/lelian/koreaninput
  • e9f01c3 cleanup and trying to figure out when to clear the buffer
  • aef983a removed unnecessary var
  • 7f17c14 clear input buffer on enter or escape

📊 Changes

4 files changed (+50 additions, -26 deletions)

View changed files

📝 src/cascadia/TerminalControl/TSFInputControl.cpp (+41 -24)
📝 src/cascadia/TerminalControl/TSFInputControl.h (+2 -2)
📝 src/cascadia/TerminalControl/TSFInputControl.idl (+1 -0)
📝 src/cascadia/TerminalControl/TermControl.cpp (+6 -0)

📄 Description

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.


🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/microsoft/terminal/pull/4796 **Author:** [@leonMSFT](https://github.com/leonMSFT) **Created:** 3/4/2020 **Status:** ✅ Merged **Merged:** 3/4/2020 **Merged by:** [@undefined](undefined) **Base:** `master` ← **Head:** `dev/lelian/koreaninput` --- ### 📝 Commits (10+) - [`cd8bc7c`](https://github.com/microsoft/terminal/commit/cd8bc7c4d60a85d4a240ba771fde3be98eeee52c) korean input seems to work, but now emojis don't work :sadface: - [`646ed57`](https://github.com/microsoft/terminal/commit/646ed57fbdc6e268dab8faab342502c2c5fd00cc) merge conflicts - [`e98d6d4`](https://github.com/microsoft/terminal/commit/e98d6d4766eecd165d296996ac3402b2929455fd) LOOKIN GUD - [`a36f8bb`](https://github.com/microsoft/terminal/commit/a36f8bb96aeb8d1526a701f3c8b401ed48fec26a) Merge branch 'master' into dev/lelian/koreaninput - [`b194b40`](https://github.com/microsoft/terminal/commit/b194b407baf85076eae094f4f622cd13c549b8a6) Merge branch 'master' into dev/lelian/koreaninput - [`d178336`](https://github.com/microsoft/terminal/commit/d1783361509d6157e1855c5c3b56f406111e8b97) Merge branch 'master' into dev/lelian/koreaninput - [`7fe9aab`](https://github.com/microsoft/terminal/commit/7fe9aabcb64d61dc25e3a298bc7731e0919db243) Merge branch 'master' into dev/lelian/koreaninput - [`e9f01c3`](https://github.com/microsoft/terminal/commit/e9f01c301707adda3e340405a426774b1cedf725) cleanup and trying to figure out when to clear the buffer - [`aef983a`](https://github.com/microsoft/terminal/commit/aef983ae0ea882c7bdd55652c58ed93b77f9333f) removed unnecessary var - [`7f17c14`](https://github.com/microsoft/terminal/commit/7f17c14c764e65d480dca7405499bd43b8b0834a) clear input buffer on enter or escape ### 📊 Changes **4 files changed** (+50 additions, -26 deletions) <details> <summary>View changed files</summary> 📝 `src/cascadia/TerminalControl/TSFInputControl.cpp` (+41 -24) 📝 `src/cascadia/TerminalControl/TSFInputControl.h` (+2 -2) 📝 `src/cascadia/TerminalControl/TSFInputControl.idl` (+1 -0) 📝 `src/cascadia/TerminalControl/TermControl.cpp` (+6 -0) </details> ### 📄 Description ## 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. --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
claunia added the pull-request label 2026-01-31 09:12:50 +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#25946