Skip to content

Commit 8a81524

Browse files
authored
Fixed caret position off by one on wrapped multiline (#834)
1 parent 7ce5be7 commit 8a81524

1 file changed

Lines changed: 2 additions & 2 deletions

File tree

richtextfx/src/main/java9/org/fxmisc/richtext/TextFlowExt.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -109,10 +109,10 @@ CharacterHit hit(double x, double y) {
109109
int charIdx = hit.getCharIndex();
110110
boolean leading = hit.isLeading();
111111

112-
if ( ! leading ) {
112+
if ( ! leading && getLineCount() > 1) {
113113
// If this is a wrapped paragraph and hit character is at end of hit line, make sure that the
114114
// "character hit" stays at the end of the hit line (and not at the beginning of the next line).
115-
leading = (getLineCount() > 1 && charIdx + 1 >= span.getStart() + span.getLength());
115+
leading = (getLineOfCharacter(charIdx) + 1 < getLineCount() && charIdx + 1 >= span.getStart() + span.getLength());
116116
}
117117

118118
if(x < lineBounds.getMinX() || x > lineBounds.getMaxX()) {

0 commit comments

Comments
 (0)