re-editor icon indicating copy to clipboard operation
re-editor copied to clipboard

Text traversal using moveCursor gets stuck at end of line and chunks/empty lines

Open hommes-doutant opened this issue 9 months ago • 3 comments

Describe the bug When using the controller moveCursor function to move the cursor right or down, it gets stuck at the end of a line (for right) or at the end of a chunk (for down).

The behaviour doesn't happen when going left or up, or in any direction when using extendSelection. The behaviour also doesn't happen

To Reproduce

  1. Create a flutter for android app (and make sure to implement key event support) or use the reqable app on android.
  2. write a few lines of code
  3. using the samsung keyboard or gboard, use the navigation functions. (Important because it works normally with a physical keyboard)
  4. the cursor gets stuck at the end of a line instead of continuing to the next line.

Expected behavior The cursor should not be stuck unless at the end of file.

Device:

  • OS: Android 12

Additional context When using the "select all" function inside the samsung keyboard, or gboard, it selects only one line. I guess it is related to the same issue.

I've attached a picture of the samsung keyboard screen that is used for text traversal, but gboard has the same and has the same behaviour.

Image

hommes-doutant avatar Mar 19 '25 13:03 hommes-doutant

I think I know why this is happening. Editor will only synchronize the current line to IME, and IME cannot know the content of other lines, so it cannot be moved.

There is a large latency in transferring huge text between Flutter and IME, which is why re-editor has higher performance than TextField.

MegatronKing avatar Mar 19 '25 14:03 MegatronKing

Thanks for the reply.

If I understand correctly, the IME thinks there is no text next so it doesn't even trigger the function moveCursor. I've added buttons that use moveCursor directly and they don't suffer from the same issue.

What I don't understand, is why the keyboard arrow down works if that's the case. But it only works, if there is text, directly under it. (It won't move to the next line if the cursor is not directly over a character).

I mentioned the "select all" issue because I thought it was related, but if it's not and if it isn't fixable due to some optimisations, I don't mind, since calling select all from a button or the context menu is available.

hommes-doutant avatar Mar 19 '25 16:03 hommes-doutant

@MegatronKing , a simple fix for this would be, to add, the previous and the next line to the IME. It's not too expensive and it fixes my problem. (The move cursor one, not selecting from the native keyboard, as it would require more work to implement well).

If you have time to review, I can make a pull request. I've also come across other bugs that I managed to fix, that I can make targeted PRs for, as well.

hommes-doutant avatar Oct 09 '25 22:10 hommes-doutant