From b4b3399a4b3d3908c0156dbf89900d63a96f89c7 Mon Sep 17 00:00:00 2001 From: julia Date: Wed, 18 Mar 2020 21:36:30 -0700 Subject: [PATCH] Fix tooltip formatting so it actually occurs. --- .../create/foundation/item/TooltipHelper.java | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/src/main/java/com/simibubi/create/foundation/item/TooltipHelper.java b/src/main/java/com/simibubi/create/foundation/item/TooltipHelper.java index f02e95f6f..337895676 100644 --- a/src/main/java/com/simibubi/create/foundation/item/TooltipHelper.java +++ b/src/main/java/com/simibubi/create/foundation/item/TooltipHelper.java @@ -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 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());