[PR #5109] [MERGED] Fix broken Chinese IME when deleting composition #26108

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

📋 Pull Request Information

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

Base: masterHead: dev/lelian/imeweird


📝 Commits (2)

📊 Changes

1 file changed (+9 additions, -0 deletions)

View changed files

📝 src/cascadia/TerminalControl/TSFInputControl.cpp (+9 -0)

📄 Description

Summary of the Pull Request

This PR fixes an out of bounds access when deleting composition during Chinese IME. What's happening is that we're receiving a CompositionCompleted before receiving the TextUpdate to tell us to delete the last character in the composition. This creates two problems for us:

  1. The final character gets sent to the Terminal when it should have been deleted.
  2. _activeTextStart gets set to _inputBuffer.length() when sending the character to the terminal, so when the TextUpdate comes right after the CompositionCompleted event, _activeTextStart is out of sync.

This PR fixes the second issue, by updating _activeTextStart during a TextUpdate in case we run into this issue.
The first issue is trickier to resolve since we assume that if the text server api tells us a composition is completed, we should send what we have. It'll be tracked here: #5110.
At the very least, this PR will let users continue to type in Chinese IME without it breaking, but it will still be annoying to see the first letter of your composition reappear after deleting it.

PR Checklist

Validation Steps Performed

Play around with Chinese IME deleting and composing, and play around with Korean and Japanese IME to see that it still works as expected.


🔄 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/5109 **Author:** [@leonMSFT](https://github.com/leonMSFT) **Created:** 3/24/2020 **Status:** ✅ Merged **Merged:** 3/25/2020 **Merged by:** [@undefined](undefined) **Base:** `master` ← **Head:** `dev/lelian/imeweird` --- ### 📝 Commits (2) - [`1b83b05`](https://github.com/microsoft/terminal/commit/1b83b0566fb56d925d30737f099e3cc0270e164c) adding min for _activeTextStart - [`5a7efaf`](https://github.com/microsoft/terminal/commit/5a7efaf37d37515d30d1b38db64fe6127dbb43d7) updating comment ### 📊 Changes **1 file changed** (+9 additions, -0 deletions) <details> <summary>View changed files</summary> 📝 `src/cascadia/TerminalControl/TSFInputControl.cpp` (+9 -0) </details> ### 📄 Description ## Summary of the Pull Request This PR fixes an out of bounds access when deleting composition during Chinese IME. What's happening is that we're receiving a CompositionCompleted before receiving the TextUpdate to tell us to delete the last character in the composition. This creates two problems for us: 1. The final character gets sent to the Terminal when it should have been deleted. 2. `_activeTextStart` gets set to `_inputBuffer.length()` when sending the character to the terminal, so when the `TextUpdate` comes right after the `CompositionCompleted` event, `_activeTextStart` is out of sync. This PR fixes the second issue, by updating `_activeTextStart` during a `TextUpdate` in case we run into this issue. The first issue is trickier to resolve since we assume that if the text server api tells us a composition is completed, we should send what we have. It'll be tracked here: #5110. At the very least, this PR will let users continue to type in Chinese IME without it breaking, but it will still be annoying to see the first letter of your composition reappear after deleting it. ## PR Checklist * [x] Closes #5054 * [x] CLA signed. If not, go over [here](https://cla.opensource.microsoft.com/microsoft/Terminal) and sign the CLA * [x] Tests added/passed ## Validation Steps Performed Play around with Chinese IME deleting and composing, and play around with Korean and Japanese IME to see that it still works as expected. --- <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:13:58 +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#26108