Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

code line cannot actually matches the line number #8

Open
dreamer2q opened this issue Mar 16, 2021 · 7 comments
Open

code line cannot actually matches the line number #8

dreamer2q opened this issue Mar 16, 2021 · 7 comments

Comments

@dreamer2q
Copy link

From https://widget.studio, when you change the font size, there may occur that actually code line cannot match line number indicator.

see screenshot for more info

image

@baderouaich
Copy link
Owner

Hi @dreamer2q, i believe the syntax view version used in https://widget.studio is a fork by @rodydavis as he mentioned in issue #6 .
Although we are trying to find a better solution to that, as we are talking i have made some changes in version 4.2.2 which i think solves #6 (still waiting for tests in your side before publishing)
@rodydavis can you give v4.2.2 a test in https://widget.studio to see if this issue solved?
Thank you!

@dreamer2q
Copy link
Author

It works much better without softWrap.

But if you enable softWrap and increase the font size, code line will overflow.

Screenshot_20210317_011901

@baderouaich
Copy link
Owner

Ah yep you're right, I have tested it again with larger font size and this problem show up...
any suggestions to solve this one guys?

@maheshj01
Copy link

You just have to calculate the number of lines ("\n") in the text of the textfield and that will give you the number of lines. You could do this using RegExp.

@rodydavis
Copy link
Contributor

I will update and let you know if it is fixed! I can also contribute back a custom TextEditingController that highlights the code and allows you to use this in a text field.

Here is a demo:

https://rodydavis.github.io/flutter_analyzer/

If you are interest in looking at the code:

https://github.com/rodydavis/flutter_analyzer/blob/master/lib/src/controller.dart

@baderouaich
Copy link
Owner

You just have to calculate the number of lines ("\n") in the text of the textfield and that will give you the number of lines. You could do this using RegExp.

yes this will work fine until softWrap is enabled, then RichText will break lines to fit the screen leaving text code unchanged. the lines will be broken in the view but text will remain the same...

@baderouaich
Copy link
Owner

I will update and let you know if it is fixed! I can also contribute back a custom TextEditingController that highlights the code and allows you to use this in a text field.

Here is a demo:

https://rodydavis.github.io/flutter_analyzer/

If you are interest in looking at the code:

https://github.com/rodydavis/flutter_analyzer/blob/master/lib/src/controller.dart

That would be great 😀! thank you @rodydavis!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants