Fix entering newline on deltas for windows (flutter/engine#32195)

* Fix entering newline

* utf8toutf16

* formatting

* Address reviews

* send *model“

* capture oldtext and selection before newline is added to model

* use model vs _active_model_ for consistency

* Formatting

* updates

Co-authored-by: Renzo Olivares <roliv@google.com>
This commit is contained in:
Renzo Olivares 2022-03-23 12:02:13 -07:00 committed by GitHub
parent 2c9315d92a
commit 47fcfe0b21

View File

@ -446,8 +446,16 @@ void TextInputPlugin::SendStateUpdateWithDelta(const TextInputModel& model,
void TextInputPlugin::EnterPressed(TextInputModel* model) {
if (input_type_ == kMultilineInputType) {
model->AddText(std::u16string({u'\n'}));
SendStateUpdate(*model);
std::u16string text_before_change = fml::Utf8ToUtf16(model->GetText());
TextRange selection_before_change = model->selection();
model->AddText(u"\n");
if (enable_delta_model) {
TextEditingDelta delta(text_before_change, selection_before_change,
u"\n");
SendStateUpdateWithDelta(*model, &delta);
} else {
SendStateUpdate(*model);
}
}
auto args = std::make_unique<rapidjson::Document>(rapidjson::kArrayType);
auto& allocator = args->GetAllocator();