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

Line numbers bug #42

Open
Plezha opened this issue Mar 26, 2023 · 7 comments
Open

Line numbers bug #42

Plezha opened this issue Mar 26, 2023 · 7 comments
Labels
bug Something isn't working

Comments

@Plezha
Copy link

Plezha commented Mar 26, 2023

Describe the bug
When line numbers is tirned on:

  • There is a blank line when swiping code to the right
  • Numbers easily overlap code

To Reproduce
To reproduce the behavior, try using line numeration
I used CodeView 1.3.7 with programmatic declaration in AndroidView:

AndroidView(
            factory = { ctx ->
                com.amrdeveloper.codeview.CodeView(ctx).apply {
                    isFocusable = true
                    isEnabled = true
                    isClickable = true
                    isFocusableInTouchMode = true
                    maxWidth = context.resources.displayMetrics.widthPixels

                    setText(text, TextView.BufferType.EDITABLE)
                    setTextColor(android.graphics.Color.WHITE)
                    setTextSize(0, 64f)


                    setEnableLineNumber(true)
                    setLineNumberTextSize(64f)
                    setLineNumberTextColor(android.graphics.Color.WHITE)

                    dropDownHorizontalOffset = 0

                    setBackgroundColor(android.graphics.Color.BLACK)

                    layoutParams = LinearLayout.LayoutParams(
                        ViewGroup.LayoutParams.WRAP_CONTENT,
                        ViewGroup.LayoutParams.WRAP_CONTENT
                    )
                    gravity = Gravity.START

                    addTextChangedListener(textWatcher)
                }
            },
)

Expected behavior
I expected line numbers to either disappear completely or not disappear at all while swiping code to the right but it does neither (see attached video).
Also, even 2-digit line number overlaps code if using same text size.
device-2023-03-27-003432.webm

Smartphone (please complete the following information):

  • Device: emulated PIxel 6

  • OS: Android 13 (API 33)

  • Device: real Xiaomi Redmi 4 Pro

  • OS: Android 6 (API 23)

Additional context
I would also like to know if it possible to let "actual" lines to go to next "visual" lines when getting out of view's bounds (something like line break). I have implemented it in Compose if that can help somehow
Tried making my own highlighter with Compose but found no way to use AnnotatedString in editable text composables.

@AmrDeveloper
Copy link
Owner

Hello @Plezha,

Thank you for reporting this issue, I found that the number overlap issue is because the current code calculates the padding with constants values but now I have updated it to use the font size, and number length and tested it with smaller and bigger sizes,

I will add the line break and improve line number drawing while sapping futures to the todo

Try it in version 1.3.8 and feel free to write any suggestions, report

Thanks
Amr Hesham

@Plezha
Copy link
Author

Plezha commented Mar 27, 2023

Thank you for swift reaction and fix. Is there a way to try updated CodeView now?

@Plezha
Copy link
Author

Plezha commented Mar 27, 2023

I also found another kind of related issue while using CodeView in HorizontalPager (which works over LazyRow):
device-2023-03-27-182348.webm

@AmrDeveloper
Copy link
Owner

Thank you for swift reaction and fix. Is there a way to try updated CodeView now?

You're most welcome, I uploaded the new version to maven and it will take about 30m and you can use it

@AmrDeveloper
Copy link
Owner

I also found another kind of related issue while using CodeView in HorizontalPager (which works over LazyRow): device-2023-03-27-182348.webm

Thank you for reporting it I will check it in the XML version then I will test it on compose, maybe we can create another version that is based on compose UI

I will check them

Thanks
Amr Hesham

@AmrDeveloper AmrDeveloper added the bug Something isn't working label Mar 27, 2023
@Plezha
Copy link
Author

Plezha commented Mar 27, 2023

I also found another kind of related issue while using CodeView in HorizontalPager (which works over LazyRow): device-2023-03-27-182348.webm

Thank you for reporting it I will check it in the XML version then I will test it on compose, maybe we can create another version that is based on compose UI

I will check them

Thanks Amr Hesham

I'm looking forward to help you If you decide to create CodeView based on Compose

@AmrDeveloper
Copy link
Owner

That's great, once i start working on it you are most welcome to join

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants