-
Notifications
You must be signed in to change notification settings - Fork 6k
Fix bug in handling delete key event for android #17393
Fix bug in handling delete key event for android #17393
Conversation
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.
Thanks for the PR! Here are just some quick comments about things we need to look at, but we should get @GaryQian to take a look as well.
One other thing is that you should include tests for this. One for each of the two problems you mention above would be perfect if possible. Look in InputConnectionAdaptorTest.java. You can run this test file locally like this:
./flutter/testing/run_tests.py --type java --java-filter io.flutter.plugin.editing.InputConnectionAdaptorTest
shell/platform/android/io/flutter/plugin/editing/InputConnectionAdaptor.java
Outdated
Show resolved
Hide resolved
shell/platform/android/io/flutter/plugin/editing/InputConnectionAdaptor.java
Outdated
Show resolved
Hide resolved
shell/platform/android/io/flutter/plugin/editing/InputConnectionAdaptor.java
Outdated
Show resolved
Hide resolved
There was also another problem in the main code before my pull request |
I wrote a test for the problems I mentioned above. |
585b91c
to
c98ffdf
Compare
@alimahdiyar Looks like there is a conflict, could you merge master? |
@justinmc Master is merged and all checks are passed successfully. |
Thanks for the changes, give me a moment to verify this is valid for all the different kinds of input. |
shell/platform/android/io/flutter/plugin/editing/InputConnectionAdaptor.java
Outdated
Show resolved
Hide resolved
It looks like there is a listener called If |
According to the API docs for |
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.
See above
Thank you for reviewing my PR. I made the needed changes to my code and TextKeyListener class is being used now. |
shell/platform/android/io/flutter/plugin/editing/InputConnectionAdaptor.java
Show resolved
Hide resolved
I worked on the problem and tried to find a better solution and finally mixed my solution with the old one.
P.S: extendLeft didn't work correctly on tests. I'm not sure but I think it needed a physical device. Anyway, I deleted the tests but confirmed everything works as good as possible on real devices. Please review again. @GaryQian @justinmc |
f5bd9fe
to
c9d1b8d
Compare
@GaryQian Can you please review again? |
So I tested with flag/complex emojis and it looks like the new version still does not handle them properly. Let me see if I can wiggle it around to handle the emojis properly. I agree with the RTL handling changes, but I would not want to regress the emoji backspace behavior. Simple emojis should be no problem as they are represented by single codepoints. |
When not mixing RTL and LTR text and writing simple one direction text, my code is using old extendRight and extendLeft functions. So if the bug exists in this scenarios the bug origin is not my code. If the problem is when you mix RTL and LTR text (which is handled by the new code), it has the benefit of fixing more problems. Thanks again for your review and working on the problem |
Hang in there, I am experiencing a strange issue where complex emojis are not being handled even with a clean, unmodified engine build. It seems that the debug local engine is somehow causing improper emoji handling? |
I didn't have devices that you reported the issue on and didn't experience the issue so I couldn't test myself. But as I said I think the problem is with bringing the caret in the wrong offset when re-placing. |
It's not that, your code might have been correct. When I run everything in release mode, it seems to start working. Still trying to isolate why this is happening. I haven't seen debug vs release differences like this before. |
Ok, so I have confirmed that the version using just the TextKeyListener directly is producing correct results when built as a release engine. If you roll it back to that version (with the tests too!), I can approve it. I'm not sure how there can be differences in the debug vs release though, the only possible causes are either a timing issue (the keyboard API can get race-y due to the jumps between dart, engine, and embedder) or a dart compiler bug where there is some tiny difference between the two builds. The GetGlyphPositionAtCoordinate() method in LibTxt is simply not being called, resulting in the incorrect caret positioning as you pointed out. Since this bug is unrelated to your fix, we can handle them separately. |
c9d1b8d
to
f9fc40e
Compare
Done |
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.
LGTM, Thanks for your patience!
@GaryQian Thanks. |
I will take care of merging it :). I'll let you know if anything needs to be fixed to pass presubmit. |
This pull request is not suitable for automatic merging in its current state.
|
@alimahdiyar Can you rebase to upstream master? There was a change made recently that is needed for the
|
f9fc40e
to
46be3c6
Compare
@GaryQian Done :) |
Landing manually, Fuchsia LUCI failure seems to be a flake. |
When typing RTL and LTR characters together in TextField, deleting a single character might cause it's previous characters from the same direction to be deleted.
Also, you can't delete a new line when typing RTL text.
This PR is for fixing these problems.