Merge pull request #97 from fuzzyweapon/tooltip-format-fix

Fix tooltip formatting so it actually occurs.
This commit is contained in:
simibubi 2020-03-19 09:47:11 +01:00 committed by GitHub
commit 078033059a
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -47,17 +47,20 @@ public class TooltipHelper {
for (int i = 0; i < indent; i++)
lineStart += " ";
String[] words = s.split(" ");
// Apply markup
String markedUp = s.replaceAll("_([^_]+)_", highlightColor + "$1" + defaultColor);
String[] words = markedUp.split(" ");
List<String> lines = new ArrayList<>();
StringBuilder currentLine = new StringBuilder(lineStart);
String word;
boolean firstWord = true;
boolean lastWord;
// Apply hard wrap
for (int i = 0; i < words.length; i++) {
String word = words[i];
if (word.matches("_.+_.?"))
word = highlightColor + word.replaceAll("\\_", "") + defaultColor;
boolean lastWord = i == words.length - 1;
word = words[i];
lastWord = i == words.length - 1;
if (!lastWord && !firstWord && currentLine.length() + word.length() > maxCharsPerLine) {
lines.add(currentLine.toString());