Fix typing multiple emojis on Windows 10 (#17213)

On Windows 10 Emojis don't finish composition until the Emoji picker
panel is closed. Each emoji is thus its own composition range.
`firstRange` thus caused only the first emoji to finish composition.
The end result was that all remaining emojis would stay around
forever, with the user entirely unable to clear them.

## Validation Steps Performed
* Windows 10 VM
* Open Emoji picker (Win+.)
* Press and hold Enter on any Emoji
* Press Esc to finish the composition
* All of the Emoji can be backspaced / deleted
This commit is contained in:
Leonard Hecker 2024-05-08 22:58:19 +02:00 committed by GitHub
parent dbac3a1fa3
commit 49e4eea60f
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -436,7 +436,7 @@ void Implementation::_doCompositionUpdate(TfEditCookie ec)
std::wstring finalizedString;
std::wstring activeComposition;
til::small_vector<Render::CompositionRange, 2> activeCompositionRanges;
bool firstRange = true;
bool activeCompositionEncountered = false;
const GUID* guids[] = { &GUID_PROP_COMPOSING, &GUID_PROP_ATTRIBUTE };
wil::com_ptr<ITfReadOnlyProperty> props;
@ -500,7 +500,9 @@ void Implementation::_doCompositionUpdate(TfEditCookie ec)
ULONG len = bufCap;
THROW_IF_FAILED(range->GetText(ec, TF_TF_MOVESTART, buf, len, &len));
if (!composing && firstRange)
// 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);
}
@ -520,7 +522,7 @@ void Implementation::_doCompositionUpdate(TfEditCookie ec)
const auto attr = _textAttributeFromAtom(atom);
activeCompositionRanges.emplace_back(totalLen, attr);
firstRange = false;
activeCompositionEncountered |= composing;
}
}