Skip to content
This repository was archived by the owner on Feb 25, 2025. It is now read-only.
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 11 additions & 0 deletions shell/platform/common/text_input_model.cc
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
#include "flutter/shell/platform/common/text_input_model.h"

#include <algorithm>
#include <regex>
#include <string>

#include "flutter/fml/string_conversion.h"
Expand Down Expand Up @@ -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) {
Expand Down
1 change: 0 additions & 1 deletion shell/platform/windows/text_input_plugin.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down