BertrandBev / code_field

A customizable code text field supporting syntax highlighting
https://bertrandbev.github.io/code_field/
MIT License
230 stars 61 forks source link

cannot select multi lines when wrap CodeField in a SingleChildScrollView #74

Open guchengxi1994 opened 1 year ago

guchengxi1994 commented 1 year ago

bug

itzhoujun commented 1 year ago

same issue

guchengxi1994 commented 1 year ago

@itzhoujun maybe try this https://github.com/akvelon/flutter-code-editor, this package contains a lot of other features

itzhoujun commented 1 year ago

@guchengxi1994 thanks.

itzhoujun commented 1 year ago

@guchengxi1994 flutter-code-editor has same issue. Any idea to fix it?

mack-at-pieces commented 1 year ago

@itzhoujun @guchengxi1994 My fork has this solved: https://github.com/mack-at-pieces/code_field. Feel free to use!

guchengxi1994 commented 1 year ago

@mack-at-pieces Great!

itzhoujun commented 1 year ago

@itzhoujun @guchengxi1994 My fork has this solved: https://github.com/mack-at-pieces/code_field. Feel free to use!

Hi, which commit is to fix it? I want to fix it at https://github.com/akvelon/flutter-code-editor

guchengxi1994 commented 1 year ago

@itzhoujun I think this one. https://github.com/BertrandBev/code_field/commit/565d61adb6de8acc56a6afe85f166cceb62ca4b3

BertrandBev commented 1 year ago

@mack-at-pieces would you mind putting together a PR to merge your fix in?

mack-at-pieces commented 1 year ago

Hi all @guchengxi1994 @BertrandBev my apologies - I forgot my fix for this isn't within the code editor itself, it's related to the implementation. If you are wrapping the CodeField with a SingleChildScrollView, then you will run into scrolling conflicts with the scroll view and the internal scrolling of the underlying TextField, which creates this buggy effect.

My solution was to eliminate any scroll widgets wrapping the CodeField and put expands: true on the CodeField itself.

What this looks like in practice using the example app in the package:

Screenshot 2023-03-21 at 10 52 43 AM Screenshot 2023-03-21 at 10 51 54 AM

There may be another fundamental change to the CodeField itself that that would solve the issue, but this is what I found for now.

mack-at-pieces commented 1 year ago

@itzhoujun I think this one. 565d61a

This fix is actually related to the scrollbar sometimes appearing in the line number column.