-
Notifications
You must be signed in to change notification settings - Fork 236
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
First visible paragraph not being styled when using ModificationObserver and moveTo() #998
Comments
So I had a look and so far I haven't been able to figure out why Position 1 is being skipped ? In the meantime here is a hack / workaround that seems to work okay. Replace the VisibleParagraphStyler.accept() method contents with the following: if ( lm.getAddedSize() > 0 )
{
int size = area.getParagraphs().size()-1;
int first = area.firstVisibleParToAllParIndex();
int p0 = lm.getFrom();
int p2 = (p0 > 0) ? p0 : 1;
p0 = Math.min( first + p0, size );
p2 = Math.min( first + p2, size );
String text = area.getText( p0, 0, p2, area.getParagraphLength( p2 ) );
if ( p0 != prevParagraph || text.length() != prevTextLength )
{
int startPos = area.getAbsolutePosition( p0, 0 );
Platform.runLater( () -> area.setStyleSpans( startPos, computeStyles.apply( text ) ) );
prevTextLength = text.length();
prevParagraph = p0;
}
} |
Think I've found the problem in the Flowless library and submitted a PR FXMisc/Flowless#83. |
While trying to create a test case for the Flowless PR, I came to the conclusion that that PR is not the correct solution. |
I am using the mechanism exemplified by JavaKeywordsDemo.java to highlight paragraphs as they become visible. This works perfectly when scrolling.
I have use-cases for moveTo() - jumping to the previous error by clicking a button, for example. This mostly works just as well, except that somehow the first visible paragraph does not get styled.
I'm new to ReactFX (and react in general) so my debugging has not been too helpful, but I did notice a suspicious behaviour. In the demo to reproduce below,
Position 1 seems to be skipped somehow, which would explain why it does not get highlighted.
Environment info:
Reproducible Demo
The below is a slightly modified JavaKeywordsDemo.java (you will need the java-keywords.css from the demos, unaltered). Pressing the '0' key calls a moveTo(currentParagraph - 10, 0), and the issue becomes visible once you start scrolling up with it.
The text was updated successfully, but these errors were encountered: