File tree Expand file tree Collapse file tree
richtextfx/src/main/java/org/fxmisc/richtext Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -1698,6 +1698,24 @@ private void followCaret() {
16981698 Bounds caretBounds = cell .getNode ().getCaretBounds (caretSelectionBind .getUnderlyingCaret ());
16991699 double graphicWidth = cell .getNode ().getGraphicPrefWidth ();
17001700 Bounds region = extendLeft (caretBounds , graphicWidth );
1701+ double scrollX = virtualFlow .getEstimatedScrollX ();
1702+
1703+ // Ordinarily when a caret ends a selection in the target paragraph and scrolling left is required to follow
1704+ // the caret then the selection won't be visible. So here we check for this scenario and adjust if needed.
1705+ if ( ! isWrapText () && scrollX > 0.0 && getParagraphSelection ( parIdx ).getLength () > 0 )
1706+ {
1707+ double visibleLeftX = cell .getNode ().getWidth () * scrollX / 100 - getWidth () + graphicWidth ;
1708+
1709+ CaretNode selectionStart = new CaretNode ( "" , this , getSelection ().getStart () );
1710+ cell .getNode ().caretsProperty ().add ( selectionStart );
1711+ Bounds startBounds = cell .getNode ().getCaretBounds ( selectionStart );
1712+ cell .getNode ().caretsProperty ().remove ( selectionStart );
1713+
1714+ if ( startBounds .getMinX () - graphicWidth < visibleLeftX ) {
1715+ region = extendLeft ( startBounds , graphicWidth );
1716+ }
1717+ }
1718+
17011719 virtualFlow .show (parIdx , region );
17021720 }
17031721
You can’t perform that action at this time.
0 commit comments