diff --git a/shell/platform/common/text_input_model.cc b/shell/platform/common/text_input_model.cc index a21fe1ff3effa..bbd67cdaf92da 100644 --- a/shell/platform/common/text_input_model.cc +++ b/shell/platform/common/text_input_model.cc @@ -5,6 +5,7 @@ #include "flutter/shell/platform/common/text_input_model.h" #include +#include #include #include "flutter/fml/string_conversion.h" @@ -79,8 +80,18 @@ void TextInputModel::UpdateComposingText(const std::u16string& text, composing_range_.collapsed() ? selection_ : composing_range_; text_.replace(rangeToDelete.start(), rangeToDelete.length(), text); composing_range_.set_end(composing_range_.start() + text.length()); + selection_ = TextRange(selection.start() + composing_range_.start(), selection.extent() + composing_range_.start()); + + bool korean_included = false; + if (text.length() > 0) { + std::wregex kor_regex(L"[ㄱ-ㅎㅏ-ㅣ가-힣]"); + korean_included = std::regex_match(text.cbegin(), text.cend(), kor_regex); + } + if (korean_included) { + selection_ = TextRange(selection.extent() + composing_range_.end()); + } } void TextInputModel::UpdateComposingText(const std::u16string& text) { diff --git a/shell/platform/windows/text_input_plugin.cc b/shell/platform/windows/text_input_plugin.cc index a67eca476c7e0..23d67d8ae2433 100644 --- a/shell/platform/windows/text_input_plugin.cc +++ b/shell/platform/windows/text_input_plugin.cc @@ -198,7 +198,6 @@ void TextInputPlugin::ComposeChangeHook(const std::u16string& text, TextRange composing_before_change = active_model_->composing_range(); active_model_->AddText(text); active_model_->UpdateComposingText(text, TextRange(cursor_pos, cursor_pos)); - std::string text_after_change = active_model_->GetText(); if (enable_delta_model) { TextEditingDelta delta = TextEditingDelta( fml::Utf8ToUtf16(text_before_change), composing_before_change, text);