code_field icon indicating copy to clipboard operation
code_field copied to clipboard

cannot select multi lines when wrap CodeField in a SingleChildScrollView

Open guchengxi1994 opened this issue 2 years ago • 11 comments

bug

guchengxi1994 avatar Jan 29 '23 07:01 guchengxi1994

same issue

itzhoujun avatar Mar 15 '23 02:03 itzhoujun

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

guchengxi1994 avatar Mar 15 '23 03:03 guchengxi1994

@guchengxi1994 thanks.

itzhoujun avatar Mar 15 '23 06:03 itzhoujun

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

itzhoujun avatar Mar 17 '23 03:03 itzhoujun

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

mack-at-pieces avatar Mar 20 '23 21:03 mack-at-pieces

@mack-at-pieces Great!

guchengxi1994 avatar Mar 21 '23 01:03 guchengxi1994

@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

itzhoujun avatar Mar 21 '23 08:03 itzhoujun

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

guchengxi1994 avatar Mar 21 '23 08:03 guchengxi1994

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

BertrandBev avatar Mar 21 '23 14:03 BertrandBev

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 avatar Mar 21 '23 14:03 mack-at-pieces

@itzhoujun I think this one. 565d61a

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

mack-at-pieces avatar Mar 21 '23 14:03 mack-at-pieces