Line numbers bug
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.
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
Thank you for swift reaction and fix. Is there a way to try updated CodeView now?
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 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
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 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
That's great, once i start working on it you are most welcome to join