|
16 | 16 | import java.util.function.IntSupplier; |
17 | 17 | import java.util.function.IntUnaryOperator; |
18 | 18 |
|
| 19 | +import javafx.application.Platform; |
19 | 20 | import javafx.beans.NamedArg; |
20 | 21 | import javafx.beans.property.BooleanProperty; |
21 | 22 | import javafx.beans.property.DoubleProperty; |
|
52 | 53 | import javafx.scene.shape.PathElement; |
53 | 54 | import javafx.scene.text.TextFlow; |
54 | 55 |
|
| 56 | +import javafx.application.Platform; |
55 | 57 | import org.fxmisc.flowless.Cell; |
56 | 58 | import org.fxmisc.flowless.VirtualFlow; |
57 | 59 | import org.fxmisc.flowless.VirtualFlowHit; |
@@ -1168,18 +1170,26 @@ public void setLineHighlighterOn( boolean show ) |
1168 | 1170 | } ); |
1169 | 1171 | } ); |
1170 | 1172 |
|
1171 | | - Consumer<Bounds> caretListener = b -> |
| 1173 | + Runnable adjustHighlighterRange = () -> |
1172 | 1174 | { |
1173 | | - if ( b.getMinY() != caretPrevY && lineHighlighter != null ) |
| 1175 | + if ( lineHighlighter != null ) |
1174 | 1176 | { |
1175 | 1177 | int p = getCurrentParagraph(); |
1176 | 1178 | int start = getCurrentLineStartInParargraph(); |
1177 | 1179 | int end = getCurrentLineEndInParargraph() + 1; // +1 for empty lines |
1178 | 1180 | lineHighlighter.selectRange( p, start, p, end ); |
| 1181 | + } |
| 1182 | + }; |
| 1183 | + |
| 1184 | + Consumer<Bounds> caretListener = b -> |
| 1185 | + { |
| 1186 | + if ( b.getMinY() != caretPrevY ) { |
| 1187 | + adjustHighlighterRange.run(); |
1179 | 1188 | caretPrevY = b.getMinY(); |
1180 | 1189 | } |
1181 | 1190 | }; |
1182 | 1191 |
|
| 1192 | + widthProperty().addListener( (ob,ov,nv) -> Platform.runLater( adjustHighlighterRange ) ); |
1183 | 1193 | caretBoundsProperty().addListener( (ob,ov,nv) -> nv.ifPresent( caretListener ) ); |
1184 | 1194 | getCaretBounds().ifPresent( caretListener ); |
1185 | 1195 | selectionSet.add( lineHighlighter ); |
|
0 commit comments