Skip to content

Commit

Permalink
Followcaret with selection update (#1059)
Browse files Browse the repository at this point in the history
  • Loading branch information
Jugen committed Dec 15, 2021
1 parent 0582484 commit f35220f
Showing 1 changed file with 1 addition and 3 deletions.
Expand Up @@ -1961,14 +1961,12 @@ private void followCaret() {
// the caret then the selection won't be visible. So here we check for this scenario and adjust if needed.
if ( ! isWrapText() && scrollX > 0.0 && getParagraphSelection( parIdx ).getLength() > 0 )
{
double visibleLeftX = paragrafBox.getWidth() * scrollX / 100 - getWidth() + graphicWidth;

CaretNode selectionStart = new CaretNode( "", this, getSelection().getStart() );
paragrafBox.caretsProperty().add( selectionStart );
Bounds startBounds = paragrafBox.getCaretBounds( selectionStart );
paragrafBox.caretsProperty().remove( selectionStart );

if ( startBounds.getMinX() - graphicWidth < visibleLeftX ) {
if ( startBounds.getMinX() - graphicWidth < scrollX ) {
region = extendLeft( startBounds, graphicWidth );
}
}
Expand Down

0 comments on commit f35220f

Please sign in to comment.