diff --git a/shell/platform/common/text_input_model.cc b/shell/platform/common/text_input_model.cc index a21fe1ff3effa..ea94830fcb9a4 100644 --- a/shell/platform/common/text_input_model.cc +++ b/shell/platform/common/text_input_model.cc @@ -79,8 +79,7 @@ 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()); + selection_ = TextRange(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..8d3e545659983 100644 --- a/shell/platform/windows/text_input_plugin.cc +++ b/shell/platform/windows/text_input_plugin.cc @@ -197,6 +197,7 @@ void TextInputPlugin::ComposeChangeHook(const std::u16string& text, std::string text_before_change = active_model_->GetText(); TextRange composing_before_change = active_model_->composing_range(); active_model_->AddText(text); + cursor_pos += active_model_->composing_range().extent(); active_model_->UpdateComposingText(text, TextRange(cursor_pos, cursor_pos)); std::string text_after_change = active_model_->GetText(); if (enable_delta_model) {