From 742fd89641c0978c026c5221af3fc1c44f033809 Mon Sep 17 00:00:00 2001 From: Jurgen Date: Wed, 28 Aug 2019 17:17:21 +0200 Subject: [PATCH] Fix highlight masking selection of text --- .../main/java/org/fxmisc/richtext/GenericStyledArea.java | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/richtextfx/src/main/java/org/fxmisc/richtext/GenericStyledArea.java b/richtextfx/src/main/java/org/fxmisc/richtext/GenericStyledArea.java index ba9f1bb76..17e0231bd 100644 --- a/richtextfx/src/main/java/org/fxmisc/richtext/GenericStyledArea.java +++ b/richtextfx/src/main/java/org/fxmisc/richtext/GenericStyledArea.java @@ -1157,11 +1157,13 @@ public void setLineHighlighterOn( boolean show ) path.getElements().addListener( (Change chg) -> { if ( chg.next() && chg.wasAdded() || chg.wasReplaced() ) { - double maxX = getLayoutBounds().getMaxX(); + double width = getLayoutBounds().getWidth(); // The path is limited to the bounds of the text, so here it's altered to the area's width - chg.getAddedSubList().stream().skip(1).limit(2).forEach( ele -> ((LineTo) ele).setX( maxX ) ); + chg.getAddedSubList().stream().skip(1).limit(2).forEach( ele -> ((LineTo) ele).setX( width ) ); // The path can wrap onto another line if enough text is inserted, so here it's trimmed if ( chg.getAddedSize() > 5 ) path.getElements().remove( 5, 10 ); + // Highlight masks the downward selection of text on the last line, so move it behind + path.toBack(); } } ); } );