-
Notifications
You must be signed in to change notification settings - Fork 9.5k
Fix visual artifacts when using QQ Wubi IME #20542
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from 2 commits
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
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
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
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -42,9 +42,15 @@ | |
| // while this method is called. The keyboard layout will be adjusted when the | ||
| // calling thread gets focus. This flag must be used with TF_TMAE_NOACTIVATETIP. | ||
| // - TF_TMAE_CONSOLE: A text service is activated for console usage. | ||
| // Some IMEs are known to use this as a hint. Particularly a Korean IME can benefit | ||
| // from this, because Korean relies on "recomposing" previously finished compositions. | ||
| // That can't work in a terminal, since we submit composed text to the shell immediately. | ||
| // TSF uses this flag in CInputContextAdapter (adapts TSF3 TIPs to TSF1 or IMM clients), | ||
|
github-advanced-security[bot] marked this conversation as resolved.
Fixed
|
||
| // flags the client as IMM-style, and disables "single character composition" for Korean IMEs. | ||
| // The latter would cause every syllable to be an "interim character": not marked as composing, | ||
| // yet still being rewritten by the IME. Since we send any non-composing text to the shell and | ||
| // can't unsend it, this would break the IME. We could fix that by recognizing `fInterimChar` | ||
|
github-advanced-security[bot] marked this conversation as resolved.
Fixed
|
||
| // and only finalizing the text in front of it of course, and conhost v1 did just that | ||
| // (see _IsInterimSelection/_MakeInterimString). But it also set TF_TMAE_CONSOLE, so there | ||
| // were no interim characters in the first place (lol). | ||
| // To test this, type "gksks" in a Korean IME: 하난 is correct, 하나ㄴ is broken. | ||
|
github-advanced-security[bot] marked this conversation as resolved.
Fixed
|
||
| // | ||
| // ...with the exception of, for the following reason: | ||
| // - TF_TMAE_UIELEMENTENABLEDONLY: This flag tells TSF that the caller wants to render its | ||
|
|
@@ -647,6 +653,11 @@ | |
| } | ||
| } | ||
|
|
||
| // Since we can't un-finalize finalized text, we only finalize text that's at the start of the document. | ||
| // In other words, don't put text that's in the middle between two active compositions into the finalized string. | ||
| const auto isActiveComposition = composing || activeCompositionEncountered; | ||
| auto& target = isActiveComposition ? activeComposition : finalizedString; | ||
|
|
||
| size_t totalLen = 0; | ||
| for (;;) | ||
| { | ||
|
|
@@ -658,17 +669,7 @@ | |
| ULONG len = bufCap; | ||
| THROW_IF_FAILED(range->GetText(ec, TF_TF_MOVESTART, buf, len, &len)); | ||
|
|
||
| // Since we can't un-finalize finalized text, we only finalize text that's at the start of the document. | ||
| // In other words, don't put text that's in the middle between two active compositions into the finalized string. | ||
| if (!composing && !activeCompositionEncountered) | ||
| { | ||
| finalizedString.append(buf, len); | ||
| } | ||
| else | ||
| { | ||
| activeComposition.append(buf, len); | ||
| } | ||
|
|
||
| target.append(buf, len); | ||
| totalLen += len; | ||
|
|
||
| if (len < bufCap) | ||
|
|
@@ -677,8 +678,10 @@ | |
| } | ||
| } | ||
|
|
||
| const auto attr = _textAttributeFromAtom(atom); | ||
| activeCompositionRanges.emplace_back(totalLen, attr); | ||
| if (isActiveComposition) | ||
| { | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. how does this fix the issue? I'm being dense |
||
| activeCompositionRanges.emplace_back(totalLen, _textAttributeFromAtom(atom)); | ||
| } | ||
|
|
||
| activeCompositionEncountered |= composing; | ||
| } | ||
|
|
||
Oops, something went wrong.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
All changes in this file exist simply to make the code exception-safe (it wasn't before).