From 51b260f4887b06ef83d10567b3e19810b25b1691 Mon Sep 17 00:00:00 2001 From: LongCat is Looong <31859944+LongCatIsLooong@users.noreply.github.com> Date: Wed, 20 Dec 2023 17:13:15 -0800 Subject: [PATCH 1/6] Fix macOS text composing --- shell/platform/common/text_input_model.cc | 15 +++++-- shell/platform/common/text_input_model.h | 14 ++++--- .../Source/FlutterTextInputPlugin.mm | 41 ++++++++----------- shell/platform/windows/text_input_plugin.cc | 4 +- 4 files changed, 38 insertions(+), 36 deletions(-) diff --git a/shell/platform/common/text_input_model.cc b/shell/platform/common/text_input_model.cc index bfdc7c42e2547..0a6a7a21f3b75 100644 --- a/shell/platform/common/text_input_model.cc +++ b/shell/platform/common/text_input_model.cc @@ -69,15 +69,22 @@ void TextInputModel::BeginComposing() { composing_range_ = TextRange(selection_.start()); } -void TextInputModel::UpdateComposingText(const std::u16string& text) { +void TextInputModel::UpdateComposingText(const std::u16string& text, + TextRange selection) { // Preserve selection if we get a no-op update to the composing region. if (text.length() == 0 && composing_range_.collapsed()) { return; } - DeleteSelected(); - text_.replace(composing_range_.start(), composing_range_.length(), text); + const TextRange& rangeToDelete = + composing_range_.collapsed() ? selection_ : composing_range_; + text_.replace(rangeToDelete.start(), rangeToDelete.length(), text); composing_range_.set_end(composing_range_.start() + text.length()); - selection_ = TextRange(composing_range_.end()); + selection_ = TextRange(selection.start() + composing_range_.start(), + selection.extent() + composing_range_.start()); +} + +void TextInputModel::UpdateComposingText(const std::u16string& text) { + UpdateComposingText(text, TextRange(text.length())); } void TextInputModel::UpdateComposingText(const std::string& text) { diff --git a/shell/platform/common/text_input_model.h b/shell/platform/common/text_input_model.h index cd03e1fc864fa..d9059cab15e50 100644 --- a/shell/platform/common/text_input_model.h +++ b/shell/platform/common/text_input_model.h @@ -57,12 +57,16 @@ class TextInputModel { // are restricted to the composing range. void BeginComposing(); - // Replaces the composing range with new UTF-16 text. + // Replaces the composing range with new UTF-16 text, and sets the selection. // - // If a selection of non-zero length exists, it is deleted if the composing - // text is non-empty. The composing range is adjusted to the length of - // |text| and the selection base and offset are set to the end of the - // composing range. + // The given |text| replaces text within the current composing range, or the + // current selection if the text wasn't composing. The composing range is + // adjusted to the length of |text|, and the |selection| describes the new + // selection range, relative to the start of the new composing range. + void UpdateComposingText(const std::u16string& text, TextRange selection); + + // Replaces the composing range with new UTF-16 text and sets the selection to + // the end of the composing text. void UpdateComposingText(const std::u16string& text); // Replaces the composing range with new UTF-8 text. diff --git a/shell/platform/darwin/macos/framework/Source/FlutterTextInputPlugin.mm b/shell/platform/darwin/macos/framework/Source/FlutterTextInputPlugin.mm index 80e7fb946a58a..f842590a35881 100644 --- a/shell/platform/darwin/macos/framework/Source/FlutterTextInputPlugin.mm +++ b/shell/platform/darwin/macos/framework/Source/FlutterTextInputPlugin.mm @@ -67,9 +67,9 @@ #pragma mark - Enums /** - * The affinity of the current cursor position. If the cursor is at a position representing - * a line break, the cursor may be drawn either at the end of the current line (upstream) - * or at the beginning of the next (downstream). + * The affinity of the current cursor position. If the cursor is at a position + * representing a soft line break, the cursor may be drawn either at the end of + * the current line (upstream) or at the beginning of the next (downstream). */ typedef NS_ENUM(NSUInteger, FlutterTextAffinity) { kFlutterTextAffinityUpstream, @@ -523,20 +523,19 @@ - (NSDictionary*)editingState { return nil; } - NSString* const textAffinity = [self textAffinityString]; - - int composingBase = _activeModel->composing() ? _activeModel->composing_range().base() : -1; - int composingExtent = _activeModel->composing() ? _activeModel->composing_range().extent() : -1; - - return @{ + NSDictionary* const dictionary = @{ kSelectionBaseKey : @(_activeModel->selection().base()), kSelectionExtentKey : @(_activeModel->selection().extent()), - kSelectionAffinityKey : textAffinity, - kSelectionIsDirectionalKey : @NO, - kComposingBaseKey : @(composingBase), - kComposingExtentKey : @(composingExtent), + kSelectionAffinityKey : [self textAffinityString], kTextKey : [NSString stringWithUTF8String:_activeModel->GetText().c_str()] ?: [NSNull null], }; + if (!_activeModel->composing()) { + return dictionary; + } + NSMutableDictionary* mutableDictionary = [dictionary mutableCopy]; + mutableDictionary[kComposingBaseKey] = @(_activeModel->composing_range().base()); + mutableDictionary[kComposingExtentKey] = @(_activeModel->composing_range().extent()); + return mutableDictionary; } - (void)updateEditState { @@ -852,19 +851,13 @@ - (void)setMarkedText:(id)string // Input string may be NSString or NSAttributedString. BOOL isAttributedString = [string isKindOfClass:[NSAttributedString class]]; - std::string marked_text = isAttributedString ? [[string string] UTF8String] : [string UTF8String]; - _activeModel->UpdateComposingText(marked_text); - - // Update the selection within the marked text. - long signedLength = static_cast(selectedRange.length); - long location = selectedRange.location + _activeModel->composing_range().base(); - long textLength = _activeModel->text_range().end(); - - size_t base = std::clamp(location, 0L, textLength); - size_t extent = std::clamp(location + signedLength, 0L, textLength); - _activeModel->SetSelection(flutter::TextRange(base, extent)); + const NSString* rawString = isAttributedString ? [string string] : string; + _activeModel->UpdateComposingText( + (const char16_t*)[rawString cStringUsingEncoding:NSUTF16StringEncoding], + flutter::TextRange(selectedRange.location, selectedRange.location + selectedRange.length)); if (_enableDeltaModel) { + std::string marked_text = [rawString UTF8String]; [self updateEditStateWithDelta:flutter::TextEditingDelta(textBeforeChange, selectionBeforeChange.collapsed() ? composingBeforeChange diff --git a/shell/platform/windows/text_input_plugin.cc b/shell/platform/windows/text_input_plugin.cc index 9cf1229b5b8f5..f523bcbbf7e21 100644 --- a/shell/platform/windows/text_input_plugin.cc +++ b/shell/platform/windows/text_input_plugin.cc @@ -197,9 +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().start(); - active_model_->UpdateComposingText(text); - active_model_->SetSelection(TextRange(cursor_pos, cursor_pos)); + active_model_->UpdateComposingText(text, TextRange(cursor_pos, cursor_pos)); std::string text_after_change = active_model_->GetText(); if (enable_delta_model) { TextEditingDelta delta = TextEditingDelta( From 3f4aec59938c86ce5652c77ab850d409744a5c5e Mon Sep 17 00:00:00 2001 From: LongCat is Looong <31859944+LongCatIsLooong@users.noreply.github.com> Date: Wed, 20 Dec 2023 19:32:31 -0800 Subject: [PATCH 2/6] fix tests --- shell/platform/common/text_input_model.cc | 2 +- shell/platform/common/text_input_model.h | 3 ++- .../common/text_input_model_unittests.cc | 11 ++++++++++ .../Source/FlutterTextInputPluginTest.mm | 20 +++++++++---------- 4 files changed, 24 insertions(+), 12 deletions(-) diff --git a/shell/platform/common/text_input_model.cc b/shell/platform/common/text_input_model.cc index 0a6a7a21f3b75..a21fe1ff3effa 100644 --- a/shell/platform/common/text_input_model.cc +++ b/shell/platform/common/text_input_model.cc @@ -70,7 +70,7 @@ void TextInputModel::BeginComposing() { } void TextInputModel::UpdateComposingText(const std::u16string& text, - TextRange selection) { + const TextRange& selection) { // Preserve selection if we get a no-op update to the composing region. if (text.length() == 0 && composing_range_.collapsed()) { return; diff --git a/shell/platform/common/text_input_model.h b/shell/platform/common/text_input_model.h index d9059cab15e50..2546e56bbe84e 100644 --- a/shell/platform/common/text_input_model.h +++ b/shell/platform/common/text_input_model.h @@ -63,7 +63,8 @@ class TextInputModel { // current selection if the text wasn't composing. The composing range is // adjusted to the length of |text|, and the |selection| describes the new // selection range, relative to the start of the new composing range. - void UpdateComposingText(const std::u16string& text, TextRange selection); + void UpdateComposingText(const std::u16string& text, + const TextRange& selection); // Replaces the composing range with new UTF-16 text and sets the selection to // the end of the composing text. diff --git a/shell/platform/common/text_input_model_unittests.cc b/shell/platform/common/text_input_model_unittests.cc index c138fd1fac3b4..9e8ed8f218a4e 100644 --- a/shell/platform/common/text_input_model_unittests.cc +++ b/shell/platform/common/text_input_model_unittests.cc @@ -403,6 +403,17 @@ TEST(TextInputModel, UpdateComposingRemovesLastComposingCharacter) { model->SetText("ACDE"); } +TEST(TextInputModel, UpdateSelectionWhileComposing) { + auto model = std::make_unique(); + model->SetText("ABCDE"); + model->BeginComposing(); + model->SetComposingRange(TextRange(4, 5), 1); + model->UpdateComposingText(u"ぴょんぴょん", TextRange(3, 6)); + EXPECT_STREQ(model->GetText().c_str(), "ABCDぴょんぴょん"); + EXPECT_EQ(model->selection(), TextRange(7, 10)); + EXPECT_EQ(model->composing_range(), TextRange(4, 10)); +} + TEST(TextInputModel, AddCodePoint) { auto model = std::make_unique(); model->AddCodePoint('A'); diff --git a/shell/platform/darwin/macos/framework/Source/FlutterTextInputPluginTest.mm b/shell/platform/darwin/macos/framework/Source/FlutterTextInputPluginTest.mm index 1202813a746e0..8134ddaa9b898 100644 --- a/shell/platform/darwin/macos/framework/Source/FlutterTextInputPluginTest.mm +++ b/shell/platform/darwin/macos/framework/Source/FlutterTextInputPluginTest.mm @@ -99,8 +99,8 @@ - (bool)testEmptyCompositionRange { EXPECT_FALSE([editingState[@"selectionIsDirectional"] boolValue]); EXPECT_EQ([editingState[@"selectionBase"] intValue], 0); EXPECT_EQ([editingState[@"selectionExtent"] intValue], 0); - EXPECT_EQ([editingState[@"composingBase"] intValue], -1); - EXPECT_EQ([editingState[@"composingExtent"] intValue], -1); + EXPECT_EQ(editingState[@"composingBase"], nullptr); + EXPECT_EQ(editingState[@"composingExtent"], nullptr); return true; } @@ -291,8 +291,8 @@ - (bool)testComposingRegionRemovedByFramework { EXPECT_FALSE([editingState[@"selectionIsDirectional"] boolValue]); EXPECT_EQ([editingState[@"selectionBase"] intValue], 2); EXPECT_EQ([editingState[@"selectionExtent"] intValue], 2); - EXPECT_EQ([editingState[@"composingBase"] intValue], -1); - EXPECT_EQ([editingState[@"composingExtent"] intValue], -1); + EXPECT_EQ(editingState[@"composingBase"], nullptr); + EXPECT_EQ(editingState[@"composingExtent"], nullptr); return true; } @@ -880,8 +880,8 @@ - (bool)testSetEditingStateWithTextEditingDelta { EXPECT_FALSE([editingState[@"selectionIsDirectional"] boolValue]); EXPECT_EQ([editingState[@"selectionBase"] intValue], 0); EXPECT_EQ([editingState[@"selectionExtent"] intValue], 0); - EXPECT_EQ([editingState[@"composingBase"] intValue], -1); - EXPECT_EQ([editingState[@"composingExtent"] intValue], -1); + EXPECT_EQ(editingState[@"composingBase"], nullptr); + EXPECT_EQ(editingState[@"composingExtent"], nullptr); return true; } @@ -1565,8 +1565,8 @@ - (bool)testInsertNewLine { EXPECT_FALSE([editingState[@"selectionIsDirectional"] boolValue]); EXPECT_EQ([editingState[@"selectionBase"] intValue], 4); EXPECT_EQ([editingState[@"selectionExtent"] intValue], 4); - EXPECT_EQ([editingState[@"composingBase"] intValue], -1); - EXPECT_EQ([editingState[@"composingExtent"] intValue], -1); + EXPECT_EQ(editingState[@"composingBase"], nullptr); + EXPECT_EQ(editingState[@"composingExtent"], nullptr); [plugin doCommandBySelector:@selector(insertNewline:)]; @@ -1577,8 +1577,8 @@ - (bool)testInsertNewLine { EXPECT_FALSE([editingState[@"selectionIsDirectional"] boolValue]); EXPECT_EQ([editingState[@"selectionBase"] intValue], 5); EXPECT_EQ([editingState[@"selectionExtent"] intValue], 5); - EXPECT_EQ([editingState[@"composingBase"] intValue], -1); - EXPECT_EQ([editingState[@"composingExtent"] intValue], -1); + EXPECT_EQ(editingState[@"composingBase"], nullptr); + EXPECT_EQ(editingState[@"composingExtent"], nullptr); return true; } From 48fb1f15338bd3d3b9eb72081e8e996716dc87ec Mon Sep 17 00:00:00 2001 From: LongCat is Looong <31859944+LongCatIsLooong@users.noreply.github.com> Date: Wed, 20 Dec 2023 21:56:42 -0800 Subject: [PATCH 3/6] fix test --- .../macos/framework/Source/FlutterTextInputPluginTest.mm | 8 -------- 1 file changed, 8 deletions(-) diff --git a/shell/platform/darwin/macos/framework/Source/FlutterTextInputPluginTest.mm b/shell/platform/darwin/macos/framework/Source/FlutterTextInputPluginTest.mm index 8134ddaa9b898..6c9e86622a7ff 100644 --- a/shell/platform/darwin/macos/framework/Source/FlutterTextInputPluginTest.mm +++ b/shell/platform/darwin/macos/framework/Source/FlutterTextInputPluginTest.mm @@ -147,7 +147,6 @@ - (bool)testSetMarkedTextWithSelectionChange { @"selectionBase" : @(5), @"selectionExtent" : @(5), @"selectionAffinity" : @"TextAffinity.upstream", - @"selectionIsDirectional" : @(NO), @"composingBase" : @(4), @"composingExtent" : @(10), @"text" : @"Textmarked", @@ -213,7 +212,6 @@ - (bool)testSetMarkedTextWithReplacementRange { @"selectionBase" : @(2), @"selectionExtent" : @(2), @"selectionAffinity" : @"TextAffinity.upstream", - @"selectionIsDirectional" : @(NO), @"composingBase" : @(1), @"composingExtent" : @(7), @"text" : @"1marked4", @@ -1622,9 +1620,6 @@ - (bool)testSendActionDoNotInsertNewLine { @"selectionBase" : @(4), @"selectionExtent" : @(4), @"selectionAffinity" : @"TextAffinity.upstream", - @"selectionIsDirectional" : @(NO), - @"composingBase" : @(-1), - @"composingExtent" : @(-1), @"text" : @"Text", }; @@ -1659,9 +1654,6 @@ - (bool)testSendActionDoNotInsertNewLine { @"selectionBase" : @(5), @"selectionExtent" : @(5), @"selectionAffinity" : @"TextAffinity.upstream", - @"selectionIsDirectional" : @(NO), - @"composingBase" : @(-1), - @"composingExtent" : @(-1), @"text" : @"Text\n", }; From 9e66e04bbac0381b1d27e1c2f5bc7878ae4a45fc Mon Sep 17 00:00:00 2001 From: LongCat is Looong <31859944+LongCatIsLooong@users.noreply.github.com> Date: Wed, 20 Dec 2023 23:45:33 -0800 Subject: [PATCH 4/6] revert unrelated changes --- .../Source/FlutterTextInputPlugin.mm | 19 +++++++------ .../Source/FlutterTextInputPluginTest.mm | 28 ++++++++++++------- 2 files changed, 28 insertions(+), 19 deletions(-) diff --git a/shell/platform/darwin/macos/framework/Source/FlutterTextInputPlugin.mm b/shell/platform/darwin/macos/framework/Source/FlutterTextInputPlugin.mm index f842590a35881..33adfa909dc65 100644 --- a/shell/platform/darwin/macos/framework/Source/FlutterTextInputPlugin.mm +++ b/shell/platform/darwin/macos/framework/Source/FlutterTextInputPlugin.mm @@ -523,19 +523,20 @@ - (NSDictionary*)editingState { return nil; } - NSDictionary* const dictionary = @{ + NSString* const textAffinity = [self textAffinityString]; + + int composingBase = _activeModel->composing() ? _activeModel->composing_range().base() : -1; + int composingExtent = _activeModel->composing() ? _activeModel->composing_range().extent() : -1; + + return @{ kSelectionBaseKey : @(_activeModel->selection().base()), kSelectionExtentKey : @(_activeModel->selection().extent()), - kSelectionAffinityKey : [self textAffinityString], + kSelectionAffinityKey : textAffinity, + kSelectionIsDirectionalKey : @NO, + kComposingBaseKey : @(composingBase), + kComposingExtentKey : @(composingExtent), kTextKey : [NSString stringWithUTF8String:_activeModel->GetText().c_str()] ?: [NSNull null], }; - if (!_activeModel->composing()) { - return dictionary; - } - NSMutableDictionary* mutableDictionary = [dictionary mutableCopy]; - mutableDictionary[kComposingBaseKey] = @(_activeModel->composing_range().base()); - mutableDictionary[kComposingExtentKey] = @(_activeModel->composing_range().extent()); - return mutableDictionary; } - (void)updateEditState { diff --git a/shell/platform/darwin/macos/framework/Source/FlutterTextInputPluginTest.mm b/shell/platform/darwin/macos/framework/Source/FlutterTextInputPluginTest.mm index 6c9e86622a7ff..1202813a746e0 100644 --- a/shell/platform/darwin/macos/framework/Source/FlutterTextInputPluginTest.mm +++ b/shell/platform/darwin/macos/framework/Source/FlutterTextInputPluginTest.mm @@ -99,8 +99,8 @@ - (bool)testEmptyCompositionRange { EXPECT_FALSE([editingState[@"selectionIsDirectional"] boolValue]); EXPECT_EQ([editingState[@"selectionBase"] intValue], 0); EXPECT_EQ([editingState[@"selectionExtent"] intValue], 0); - EXPECT_EQ(editingState[@"composingBase"], nullptr); - EXPECT_EQ(editingState[@"composingExtent"], nullptr); + EXPECT_EQ([editingState[@"composingBase"] intValue], -1); + EXPECT_EQ([editingState[@"composingExtent"] intValue], -1); return true; } @@ -147,6 +147,7 @@ - (bool)testSetMarkedTextWithSelectionChange { @"selectionBase" : @(5), @"selectionExtent" : @(5), @"selectionAffinity" : @"TextAffinity.upstream", + @"selectionIsDirectional" : @(NO), @"composingBase" : @(4), @"composingExtent" : @(10), @"text" : @"Textmarked", @@ -212,6 +213,7 @@ - (bool)testSetMarkedTextWithReplacementRange { @"selectionBase" : @(2), @"selectionExtent" : @(2), @"selectionAffinity" : @"TextAffinity.upstream", + @"selectionIsDirectional" : @(NO), @"composingBase" : @(1), @"composingExtent" : @(7), @"text" : @"1marked4", @@ -289,8 +291,8 @@ - (bool)testComposingRegionRemovedByFramework { EXPECT_FALSE([editingState[@"selectionIsDirectional"] boolValue]); EXPECT_EQ([editingState[@"selectionBase"] intValue], 2); EXPECT_EQ([editingState[@"selectionExtent"] intValue], 2); - EXPECT_EQ(editingState[@"composingBase"], nullptr); - EXPECT_EQ(editingState[@"composingExtent"], nullptr); + EXPECT_EQ([editingState[@"composingBase"] intValue], -1); + EXPECT_EQ([editingState[@"composingExtent"] intValue], -1); return true; } @@ -878,8 +880,8 @@ - (bool)testSetEditingStateWithTextEditingDelta { EXPECT_FALSE([editingState[@"selectionIsDirectional"] boolValue]); EXPECT_EQ([editingState[@"selectionBase"] intValue], 0); EXPECT_EQ([editingState[@"selectionExtent"] intValue], 0); - EXPECT_EQ(editingState[@"composingBase"], nullptr); - EXPECT_EQ(editingState[@"composingExtent"], nullptr); + EXPECT_EQ([editingState[@"composingBase"] intValue], -1); + EXPECT_EQ([editingState[@"composingExtent"] intValue], -1); return true; } @@ -1563,8 +1565,8 @@ - (bool)testInsertNewLine { EXPECT_FALSE([editingState[@"selectionIsDirectional"] boolValue]); EXPECT_EQ([editingState[@"selectionBase"] intValue], 4); EXPECT_EQ([editingState[@"selectionExtent"] intValue], 4); - EXPECT_EQ(editingState[@"composingBase"], nullptr); - EXPECT_EQ(editingState[@"composingExtent"], nullptr); + EXPECT_EQ([editingState[@"composingBase"] intValue], -1); + EXPECT_EQ([editingState[@"composingExtent"] intValue], -1); [plugin doCommandBySelector:@selector(insertNewline:)]; @@ -1575,8 +1577,8 @@ - (bool)testInsertNewLine { EXPECT_FALSE([editingState[@"selectionIsDirectional"] boolValue]); EXPECT_EQ([editingState[@"selectionBase"] intValue], 5); EXPECT_EQ([editingState[@"selectionExtent"] intValue], 5); - EXPECT_EQ(editingState[@"composingBase"], nullptr); - EXPECT_EQ(editingState[@"composingExtent"], nullptr); + EXPECT_EQ([editingState[@"composingBase"] intValue], -1); + EXPECT_EQ([editingState[@"composingExtent"] intValue], -1); return true; } @@ -1620,6 +1622,9 @@ - (bool)testSendActionDoNotInsertNewLine { @"selectionBase" : @(4), @"selectionExtent" : @(4), @"selectionAffinity" : @"TextAffinity.upstream", + @"selectionIsDirectional" : @(NO), + @"composingBase" : @(-1), + @"composingExtent" : @(-1), @"text" : @"Text", }; @@ -1654,6 +1659,9 @@ - (bool)testSendActionDoNotInsertNewLine { @"selectionBase" : @(5), @"selectionExtent" : @(5), @"selectionAffinity" : @"TextAffinity.upstream", + @"selectionIsDirectional" : @(NO), + @"composingBase" : @(-1), + @"composingExtent" : @(-1), @"text" : @"Text\n", }; From 57ed46ef00f537b506253a3a894885d5460a9258 Mon Sep 17 00:00:00 2001 From: LongCat is Looong <31859944+LongCatIsLooong@users.noreply.github.com> Date: Thu, 21 Dec 2023 00:15:42 -0800 Subject: [PATCH 5/6] Fix tests --- .../macos/framework/Source/FlutterTextInputPluginTest.mm | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/shell/platform/darwin/macos/framework/Source/FlutterTextInputPluginTest.mm b/shell/platform/darwin/macos/framework/Source/FlutterTextInputPluginTest.mm index 1202813a746e0..ef991758f49e8 100644 --- a/shell/platform/darwin/macos/framework/Source/FlutterTextInputPluginTest.mm +++ b/shell/platform/darwin/macos/framework/Source/FlutterTextInputPluginTest.mm @@ -945,8 +945,8 @@ - (bool)testOperationsThatTriggerDelta { @"deltaText" : @"marked text", @"deltaStart" : @(14), @"deltaEnd" : @(14), - @"selectionBase" : @(25), - @"selectionExtent" : @(25), + @"selectionBase" : @(14), + @"selectionExtent" : @(15), @"selectionAffinity" : @"TextAffinity.upstream", @"selectionIsDirectional" : @(false), @"composingBase" : @(14), @@ -1030,7 +1030,7 @@ - (bool)testComposingWithDelta { @"deltaText" : @"m", @"deltaStart" : @(0), @"deltaEnd" : @(0), - @"selectionBase" : @(1), + @"selectionBase" : @(0), @"selectionExtent" : @(1), @"selectionAffinity" : @"TextAffinity.upstream", @"selectionIsDirectional" : @(false), From ecf837539581f90283e3e2449ea76ed2a0750df2 Mon Sep 17 00:00:00 2001 From: LongCat is Looong <31859944+LongCatIsLooong@users.noreply.github.com> Date: Thu, 21 Dec 2023 09:07:45 -0800 Subject: [PATCH 6/6] Fix tests --- .../Source/FlutterTextInputPluginTest.mm | 20 +++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/shell/platform/darwin/macos/framework/Source/FlutterTextInputPluginTest.mm b/shell/platform/darwin/macos/framework/Source/FlutterTextInputPluginTest.mm index ef991758f49e8..e3a203803d489 100644 --- a/shell/platform/darwin/macos/framework/Source/FlutterTextInputPluginTest.mm +++ b/shell/platform/darwin/macos/framework/Source/FlutterTextInputPluginTest.mm @@ -1060,8 +1060,8 @@ - (bool)testComposingWithDelta { @"deltaText" : @"ma", @"deltaStart" : @(0), @"deltaEnd" : @(1), - @"selectionBase" : @(2), - @"selectionExtent" : @(2), + @"selectionBase" : @(0), + @"selectionExtent" : @(1), @"selectionAffinity" : @"TextAffinity.upstream", @"selectionIsDirectional" : @(false), @"composingBase" : @(0), @@ -1090,8 +1090,8 @@ - (bool)testComposingWithDelta { @"deltaText" : @"mar", @"deltaStart" : @(0), @"deltaEnd" : @(2), - @"selectionBase" : @(3), - @"selectionExtent" : @(3), + @"selectionBase" : @(0), + @"selectionExtent" : @(1), @"selectionAffinity" : @"TextAffinity.upstream", @"selectionIsDirectional" : @(false), @"composingBase" : @(0), @@ -1120,8 +1120,8 @@ - (bool)testComposingWithDelta { @"deltaText" : @"mark", @"deltaStart" : @(0), @"deltaEnd" : @(3), - @"selectionBase" : @(4), - @"selectionExtent" : @(4), + @"selectionBase" : @(0), + @"selectionExtent" : @(1), @"selectionAffinity" : @"TextAffinity.upstream", @"selectionIsDirectional" : @(false), @"composingBase" : @(0), @@ -1150,8 +1150,8 @@ - (bool)testComposingWithDelta { @"deltaText" : @"marke", @"deltaStart" : @(0), @"deltaEnd" : @(4), - @"selectionBase" : @(5), - @"selectionExtent" : @(5), + @"selectionBase" : @(0), + @"selectionExtent" : @(1), @"selectionAffinity" : @"TextAffinity.upstream", @"selectionIsDirectional" : @(false), @"composingBase" : @(0), @@ -1180,8 +1180,8 @@ - (bool)testComposingWithDelta { @"deltaText" : @"marked", @"deltaStart" : @(0), @"deltaEnd" : @(5), - @"selectionBase" : @(6), - @"selectionExtent" : @(6), + @"selectionBase" : @(0), + @"selectionExtent" : @(1), @"selectionAffinity" : @"TextAffinity.upstream", @"selectionIsDirectional" : @(false), @"composingBase" : @(0),