reqable / re-editor

Re-Editor is a powerful lightweight text and code editor widget.
https://pub.dev/packages/re_editor
MIT License
510 stars 51 forks source link

Double newline on pressing return on iOS #42

Closed pawel-t-wolny closed 2 weeks ago

pawel-t-wolny commented 2 weeks ago

Describe the bug When pressing "return," two new lines are inserted instead of one. I have run the editor on Android and iOS, and it only occurs on iOS. Also, it seems to occur in the Reqable app code editor.

To Reproduce Steps to reproduce the behavior:

  1. Press "return" while the editor is open

Expected behavior Two new lines instead of one will be added.

Screenshots

https://github.com/user-attachments/assets/2bfaa67d-59c9-4f0c-b699-01b4d63bd67d

Same thing happens in Reqable:

Sample Image

Device:

Additional context I have done some digging and it seems that the culprit is in lines 95-100 of code in the _code_input.dart file:

 @override
  void performAction(TextInputAction action) {
    if (action == TextInputAction.newline) {
      _controller.applyNewLine();
    }
  }

When I commented out _controller.applyNewLine(); the problem disappeared and everything else seemed to work fine in both Android and iOS.

Also thank you for creating this amazing editor!

MegatronKing commented 2 weeks ago

Thanks, we have fixed this.