Skip to content

Commit

Permalink
Fix VisTextField crash when text has newlines (#337)
Browse files Browse the repository at this point in the history
  • Loading branch information
fgnm authored Aug 29, 2020
1 parent 66eec54 commit 171894e
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion ui/src/main/java/com/kotcrab/vis/ui/widget/VisTextField.java
Original file line number Diff line number Diff line change
Expand Up @@ -437,7 +437,7 @@ void updateDisplayText () {
} else
displayText = newDisplayText;

layout.setText(font, displayText);
layout.setText(font, displayText.toString().replace('\r', ' ').replace('\n', ' '));
glyphPositions.clear();
float x = 0;
if (layout.runs.size > 0) {
Expand All @@ -457,6 +457,9 @@ void updateDisplayText () {
}
glyphPositions.add(x);

visibleTextStart = Math.min(visibleTextStart, glyphPositions.size);
visibleTextEnd = MathUtils.clamp(visibleTextEnd, visibleTextStart, glyphPositions.size);

if (selectionStart > newDisplayText.length()) selectionStart = textLength;
}

Expand Down

0 comments on commit 171894e

Please sign in to comment.