Win32: fix window commits last char when deleting text with IME (flutter/engine#32565)

This commit is contained in:
moko256
2022-04-16 03:09:05 +09:00
committed by GitHub
parent c343fd5735
commit 15e077fa4b
2 changed files with 22 additions and 0 deletions

View File

@@ -212,6 +212,11 @@ void WindowWin32::OnImeComposition(UINT const message,
// Update the IME window position.
text_input_manager_->UpdateImeWindow();
if (lparam == 0) {
OnComposeChange(u"", 0);
OnComposeCommit();
}
if (lparam & GCS_COMPSTR) {
// Read the in-progress composing string.
long pos = text_input_manager_->GetComposingCursorPosition();

View File

@@ -115,6 +115,23 @@ TEST(MockWin32Window, OnImeCompositionComposeAndResult) {
GCS_COMPSTR | GCS_RESULTSTR);
}
TEST(MockWin32Window, OnImeCompositionClearChange) {
MockTextInputManagerWin32* text_input_manager =
new MockTextInputManagerWin32();
std::unique_ptr<TextInputManagerWin32> text_input_manager_ptr(
text_input_manager);
MockWin32Window window(std::move(text_input_manager_ptr));
EXPECT_CALL(window, OnComposeChange(std::u16string(u""), 0)).Times(1);
EXPECT_CALL(window, OnComposeCommit()).Times(1);
ON_CALL(window, OnImeComposition)
.WillByDefault(Invoke(&window, &MockWin32Window::CallOnImeComposition));
EXPECT_CALL(window, OnImeComposition(_, _, _)).Times(1);
// send an IME_COMPOSITION event that contains both the result string and the
// composition string.
window.InjectWindowMessage(WM_IME_COMPOSITION, 0, 0);
}
TEST(MockWin32Window, HorizontalScroll) {
MockWin32Window window;
const int scroll_amount = 10;