Skip to content

Commit

Permalink
Fix typing multiple emojis on Windows 10 (#17213)
Browse files Browse the repository at this point in the history
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
  • Loading branch information
lhecker authored May 8, 2024
1 parent dbac3a1 commit 49e4eea
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions src/tsf/Implementation.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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);
}
Expand All @@ -520,7 +522,7 @@ void Implementation::_doCompositionUpdate(TfEditCookie ec)
const auto attr = _textAttributeFromAtom(atom);
activeCompositionRanges.emplace_back(totalLen, attr);

firstRange = false;
activeCompositionEncountered |= composing;
}
}

Expand Down

0 comments on commit 49e4eea

Please sign in to comment.