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

codeArea.getVisibleParagraphs() find lost some line #1182

Open
xiaofanku opened this issue Mar 26, 2023 · 1 comment
Open

codeArea.getVisibleParagraphs() find lost some line #1182

xiaofanku opened this issue Mar 26, 2023 · 1 comment

Comments

@xiaofanku
Copy link

I use java KeywordsDemo. Start filling the content area with empty content. Then copy a long piece of code and paste it into the codeArea, printing the parameters of the computeHighlighting method and finding that there is a behavior of missing lines. Only a few more scrolls will work properly。

like this:
2023-03-26 154723

@Jugen
Copy link
Collaborator

Jugen commented Mar 27, 2023

The problem is most likely in this section of code:

        public void accept( ListModification<? extends Paragraph<PS, SEG, S>> lm )
        {
            if ( lm.getAddedSize() > 0 ) Platform.runLater( () ->
            {
                int paragraph = Math.min( area.firstVisibleParToAllParIndex() + lm.getFrom(), area.getParagraphs().size()-1 );
                String text = area.getText( paragraph, 0, paragraph, area.getParagraphLength( paragraph ) );


                if ( paragraph != prevParagraph || text.length() != prevTextLength )
                {
                    if ( paragraph < area.getParagraphs().size()-1 )
                    {
                        int startPos = area.getAbsolutePosition( paragraph, 0 );
                        area.setStyleSpans( startPos, computeStyles.apply( text ) );
                    }
                    prevTextLength = text.length();
                    prevParagraph = paragraph;
                }
            });
        }

I see it uses lm.getFrom() but not lm.getTo() ? Maybe that's the problem ?
Or maybe it has something to do with the line: "if ( paragraph != prevParagraph || text.length() != prevTextLength )" ?
Or possibly something else ?

If you can improve the code a PR will be welcome :-)

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

2 participants