mirror of
https://github.com/flutter/flutter.git
synced 2026-02-20 02:29:02 +08:00
[Windows] Google Japanese Input, composing text doesn't rendered after commit text partially (flutter/engine#33605)
Reproducible steps is in flutter/flutter#102021. Fixes flutter/flutter#102021. No changes in [flutter/tests] repo.
This commit is contained in:
parent
368b5cc6a8
commit
601e178945
@ -233,15 +233,9 @@ void WindowWin32::OnImeComposition(UINT const message,
|
||||
OnComposeCommit();
|
||||
}
|
||||
|
||||
if (lparam & GCS_COMPSTR) {
|
||||
// Read the in-progress composing string.
|
||||
long pos = text_input_manager_->GetComposingCursorPosition();
|
||||
std::optional<std::u16string> text =
|
||||
text_input_manager_->GetComposingString();
|
||||
if (text) {
|
||||
OnComposeChange(text.value(), pos);
|
||||
}
|
||||
}
|
||||
// Process GCS_RESULTSTR at fisrt, because Google Japanese Input and ATOK send
|
||||
// both GCS_RESULTSTR and GCS_COMPSTR to commit composed text and send new
|
||||
// composing text.
|
||||
if (lparam & GCS_RESULTSTR) {
|
||||
// Commit but don't end composing.
|
||||
// Read the committed composing string.
|
||||
@ -252,6 +246,15 @@ void WindowWin32::OnImeComposition(UINT const message,
|
||||
OnComposeCommit();
|
||||
}
|
||||
}
|
||||
if (lparam & GCS_COMPSTR) {
|
||||
// Read the in-progress composing string.
|
||||
long pos = text_input_manager_->GetComposingCursorPosition();
|
||||
std::optional<std::u16string> text =
|
||||
text_input_manager_->GetComposingString();
|
||||
if (text) {
|
||||
OnComposeChange(text.value(), pos);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void WindowWin32::OnImeEndComposition(UINT const message,
|
||||
|
||||
@ -7,6 +7,7 @@
|
||||
#include "gtest/gtest.h"
|
||||
|
||||
using testing::_;
|
||||
using testing::InSequence;
|
||||
using testing::Invoke;
|
||||
using testing::Return;
|
||||
|
||||
@ -87,24 +88,34 @@ TEST(MockWin32Window, OnImeCompositionResult) {
|
||||
window.InjectWindowMessage(WM_IME_COMPOSITION, 0, GCS_RESULTSTR);
|
||||
}
|
||||
|
||||
TEST(MockWin32Window, OnImeCompositionComposeAndResult) {
|
||||
TEST(MockWin32Window, OnImeCompositionResultAndCompose) {
|
||||
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(*text_input_manager, GetComposingString())
|
||||
.WillRepeatedly(
|
||||
Return(std::optional<std::u16string>(std::u16string(u"nihao"))));
|
||||
EXPECT_CALL(*text_input_manager, GetResultString())
|
||||
.WillRepeatedly(
|
||||
Return(std::optional<std::u16string>(std::u16string(u"`}"))));
|
||||
|
||||
// This situation is that Google Japanese Input finished composing "今日" in
|
||||
// "今日は" but is still composing "は".
|
||||
{
|
||||
InSequence dummy;
|
||||
EXPECT_CALL(*text_input_manager, GetResultString())
|
||||
.WillRepeatedly(
|
||||
Return(std::optional<std::u16string>(std::u16string(u"今日"))));
|
||||
EXPECT_CALL(*text_input_manager, GetComposingString())
|
||||
.WillRepeatedly(
|
||||
Return(std::optional<std::u16string>(std::u16string(u"は"))));
|
||||
}
|
||||
{
|
||||
InSequence dummy;
|
||||
EXPECT_CALL(window, OnComposeChange(std::u16string(u"今日"), 0)).Times(1);
|
||||
EXPECT_CALL(window, OnComposeCommit()).Times(1);
|
||||
EXPECT_CALL(window, OnComposeChange(std::u16string(u"は"), 0)).Times(1);
|
||||
}
|
||||
|
||||
EXPECT_CALL(*text_input_manager, GetComposingCursorPosition())
|
||||
.WillRepeatedly(Return((int)0));
|
||||
|
||||
EXPECT_CALL(window, OnComposeChange(std::u16string(u"nihao"), 0)).Times(1);
|
||||
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);
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user