-
Notifications
You must be signed in to change notification settings - Fork 6k
[iOS TextInputPlugin] adjust the markedTextRange when replacing text. #46603
[iOS TextInputPlugin] adjust the markedTextRange when replacing text. #46603
Conversation
a0f4ec6 to
2bf714a
Compare
9fb835d to
8ddf821
Compare
8ddf821 to
12a3d68
Compare
86b3df7 to
62ae972
Compare
| // documentation but UITextField always sets markedTextRange to nil, | ||
| // and collapses the selection to the end of the new replacement text. | ||
| range.location += text.length; | ||
| range.length = 0; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why is this stomping the parameter instead of making a new range (and then replacing that new range with the clamped version)? Writing to parameters is generally bad for readability.
|
|
||
| NSUInteger selectionLocation = markedSelectedRange.location + markedTextRange.location; | ||
| selectedRange = NSMakeRange(selectionLocation, markedSelectedRange.length); | ||
| markedSelectedRange.location += newMarkedRange.location; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please use a new variable rather than overwriting the param.
| - (BOOL)isVisibleToAutofill; | ||
| - (id<FlutterTextInputDelegate>)textInputDelegate; | ||
| - (void)configureWithDictionary:(NSDictionary*)configuration; | ||
| - (void)replaceRangeLocal:(NSRange)range withText:(NSString*)text; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why can't the behavior be tested via the text input protocol, rather than internal implementation details?
|
I may need some help understanding this change. Could you update the PR description with more details? |
0f23d4d to
b1d2846
Compare
|
PR description updated. |
hellohuanlin
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Overall makes sense. Just 1 question
| ? currentMarkedTextRange.range | ||
| : _selectedTextRange.range; | ||
| // No need to call replaceRangeLocal as this method always adjusts the | ||
| // selected/marked text ranges anyways. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I am a bit lost here. Can you explain more why we had this before, and we removed it now?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
replaceRangeLocal also changes the selected text range and the marked text range, based on the original selected text range and the marked text range and the text replacement. It's not needed in this method because with this method the caller always have to specify a new selected range and marked range anyways.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is the the same reason we removed the markedText state?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
markedText was never used.
stuartmorgan-g
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Code LGTM
Just to be safe, have you checked any issues/behaviors referenced in the PRs that created the logic you are replacing, to make sure nothing is being regressed (that wasn't sufficiently unit tested)?
b1d2846 to
97f0a33
Compare
|
i've tested this patch on ios17 simulator and it worked fine, and it does fix the framework assert. |
…136844) flutter/engine@6caee32...b67edb0 2023-10-18 [email protected] [iOS TextInputPlugin] adjust the markedTextRange when replacing text. (flutter/engine#46603) 2023-10-18 [email protected] Reland: Remove the frontend server wrapper (flutter/engine#47010) 2023-10-18 [email protected] Roll Skia from 9880c4006735 to ef0e93524e7d (1 revision) (flutter/engine#47069) 2023-10-18 [email protected] Roll Skia from 523f04f1a898 to 9880c4006735 (1 revision) (flutter/engine#47067) 2023-10-18 [email protected] Roll Skia from ccd07c6f5042 to 523f04f1a898 (1 revision) (flutter/engine#47065) If this roll has caused a breakage, revert this CL and stop the roller using the controls here: https://autoroll.skia.org/r/flutter-engine-flutter-autoroll Please CC [email protected],[email protected],[email protected] on the revert to ensure that a human is aware of the problem. To file a bug in Flutter: https://github.com/flutter/flutter/issues/new/choose To report a problem with the AutoRoller itself, please file a bug: https://issues.skia.org/issues/new?component=1389291&template=1850622 Documentation for the AutoRoller is here: https://skia.googlesource.com/buildbot/+doc/main/autoroll/README.md
…#46603) Fixes flutter/flutter#130880 , by making sure when the text is cleared the `markedTextRange` is cleared with it. `[UITextField replaceRange:withText:]` always sets the selection range to the end of the replacement text, and removes the current `markedTextRange`. This PR makes the input plugin do the same in the `replaceRange:withText:` implementation. [C++, Objective-C, Java style guides]: https://github.com/flutter/engine/blob/main/CONTRIBUTING.md#style
Fixes flutter/flutter#130880 , by making sure when the text is cleared the
markedTextRangeis cleared with it.[UITextField replaceRange:withText:]always sets the selection range to the end of the replacement text, and removes the currentmarkedTextRange. This PR makes the input plugin do the same in thereplaceRange:withText:implementation.Pre-launch Checklist
///).If you need help, consider asking for advice on the #hackers-new channel on Discord.