Highlights icon indicating copy to clipboard operation
Highlights copied to clipboard

Line comment highlights the rest of the code as a string when `'` is used

Open Nek-12 opened this issue 1 year ago • 5 comments

You can reproduce the issue here: https://opensource.respawn.pro/FlowMVI/sample/ (Decompose integration item)

What's interesting, it seems that if the comment is not indented, then the bug does not occur. This started happening after the update from 0.8 to 0.9

Screenshot_2024-05-25-13-02-59-47_edc8c6346e7eebe0db8ca5df99729f24

Nek-12 avatar May 25 '24 10:05 Nek-12

Okay this looks serious, I think we will have this fixed in next versions

tmaxxdd avatar Aug 11 '24 05:08 tmaxxdd

@Nek-12 I checked the fragment of yours code inn the sample of 1.0.0 version.

Input

class PagesComponent(
        context: ComponentContext,
        container: () -> PagesContainer, // inject using DI or create 
) : ComponentContext by context,
    PagesStore by context.retainedStore(factory = container) {
    
private val navigator = PagesNavigation<PageConfig>()

val pages = childPages(
    source = navigator,
    serializer = PageConfig.serializer,
    initialPages = { Pages(items = List(5) { PageConfig(it) }) },
    childFactory = ::PageComponent,
)

init {
// subscribe to the store following the component's lifecycle
subscribe {
    actions.collect { action ->
        when (action) {
            is SelectPage -> navigator.select(action.index)
        }
    }
}

Output

After analysis there has been found:
marks = ( ( ( ( ( ( ( ( ( ( ) ) ) ) ) ) ) ) ) ) - - - > > > > = = = = = = = = { { { { { { { < } } } } }
punctuations = : : : : : , , , , , , , . . . . .
keywords = class by by private val val when is
strings = 
literals = 5
comments = // inject using DI or create  // subscribe to the store following the component's lifecycle
multilineComments = 
annotations = 
kotlin.Unit

Probably the problem belongs to KodeView so please recheck that

tmaxxdd avatar Sep 14 '24 20:09 tmaxxdd

Interesting. We are using a fork of code view that processes the annotations async on a different thread, so I will try to fork it again from a more fresh commit to see if anything changes

Nek-12 avatar Sep 15 '24 04:09 Nek-12

image

This is what I see on the latest version. I tried updating the KodeView but that didn't help, however you can see the behavior is different now. I am pretty sure the problem is in the ' symbol which tells the library that a string has started.

Nek-12 avatar Sep 19 '24 06:09 Nek-12

Everything until the end of line should be considered a comment when // is used

Nek-12 avatar Sep 19 '24 06:09 Nek-12

@Nek-12 Thanks for precise reproduction. Indeed that was a small gap in logic. This should be fixed in published 0.9.3

tmaxxdd avatar Oct 10 '24 05:10 tmaxxdd