Skip to content

Commit

Permalink
Fix Ctrl+A and Ctrl+End fold navigation (#986)
Browse files Browse the repository at this point in the history
  • Loading branch information
Jugen authored Nov 30, 2020
1 parent feb2700 commit 3af16d3
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -1470,6 +1470,10 @@ private void skipOverFoldedParagraphs( ObservableValue<? extends Integer> ob, In
{
if ( getCell( newParagraph ).isFolded() )
{
// Prevent Ctrl+A and Ctrl+End breaking when the last paragraph is folded
// github.com/FXMisc/RichTextFX/pull/965#issuecomment-706268116
if ( newParagraph == getParagraphs().size() - 1 ) return;

int skip = (newParagraph - prevParagraph > 0) ? +1 : -1;
int p = newParagraph + skip;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -240,7 +240,7 @@ public Paragraph<PS, SEG, S> getParagraph() {

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

0 comments on commit 3af16d3

Please sign in to comment.