Skip to content

Commit 3af16d3

Browse files
authored
Fix Ctrl+A and Ctrl+End fold navigation (#986)
1 parent feb2700 commit 3af16d3

2 files changed

Lines changed: 5 additions & 1 deletion

File tree

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

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1470,6 +1470,10 @@ private void skipOverFoldedParagraphs( ObservableValue<? extends Integer> ob, In
14701470
{
14711471
if ( getCell( newParagraph ).isFolded() )
14721472
{
1473+
// Prevent Ctrl+A and Ctrl+End breaking when the last paragraph is folded
1474+
// github.com/FXMisc/RichTextFX/pull/965#issuecomment-706268116
1475+
if ( newParagraph == getParagraphs().size() - 1 ) return;
1476+
14731477
int skip = (newParagraph - prevParagraph > 0) ? +1 : -1;
14741478
int p = newParagraph + skip;
14751479

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -240,7 +240,7 @@ public Paragraph<PS, SEG, S> getParagraph() {
240240

241241
public <T extends Node & Caret> double getCaretOffsetX(T caret) {
242242
layout(); // ensure layout, is a no-op if not dirty
243-
checkWithinParagraph(caret);
243+
if ( isVisible() /* notFolded */ ) checkWithinParagraph(caret);
244244
Bounds bounds = caret.getLayoutBounds();
245245
return (bounds.getMinX() + bounds.getMaxX()) / 2;
246246
}

0 commit comments

Comments
 (0)