Skip to content

Commit e9c112b

Browse files
authored
Updated visibleParToAllParIndex (#1002)
1 parent 4cc49c3 commit e9c112b

1 file changed

Lines changed: 8 additions & 1 deletion

File tree

richtextfx/src/main/java/org/fxmisc/richtext/GenericStyledArea.java

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -984,7 +984,14 @@ public final int visibleParToAllParIndex(int visibleParIndex) {
984984
getVisibleParagraphs().size() - 1, visibleParIndex)
985985
);
986986
}
987-
return virtualFlow.visibleCells().get( visibleParIndex ).getNode().getIndex();
987+
988+
Cell<Paragraph<PS,SEG,S>, ParagraphBox<PS,SEG,S>> visibleCell = null;
989+
990+
if ( visibleParIndex > 0 ) visibleCell = virtualFlow.visibleCells().get( visibleParIndex );
991+
else visibleCell = virtualFlow.getCellIfVisible( virtualFlow.getFirstVisibleIndex() )
992+
.orElseGet( () -> virtualFlow.visibleCells().get( visibleParIndex ) );
993+
994+
return visibleCell.getNode().getIndex();
988995
}
989996

990997
@Override

0 commit comments

Comments
 (0)