Skip to content

Line numbers bug #42

Description

@Plezha

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.

Activity

  1. added a commit that references this issue on Mar 27, 2023
  2. AmrDeveloper commented on Mar 27, 2023

    @AmrDeveloper
    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

  3. Plezha commented on Mar 27, 2023

    @Plezha
    Author

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

  4. Plezha commented on Mar 27, 2023

    @Plezha
    Author

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

  5. AmrDeveloper commented on Mar 27, 2023

    @AmrDeveloper
    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

  6. AmrDeveloper commented on Mar 27, 2023

    @AmrDeveloper
    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

  7. Plezha commented on Mar 27, 2023

    @Plezha
    Author

    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

  8. AmrDeveloper commented on Mar 31, 2023

    @AmrDeveloper
    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

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions