From eba73d6db4b1a2113ecbe02e3087202fb8e8e86b Mon Sep 17 00:00:00 2001 From: NorbiPeti Date: Wed, 28 Dec 2016 01:12:10 +0100 Subject: [PATCH] Probably fixed escape logic --- .../chat/formatting/ChatFormatter.java | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/src/main/java/buttondevteam/chat/formatting/ChatFormatter.java b/src/main/java/buttondevteam/chat/formatting/ChatFormatter.java index 6c50f77..3c7170d 100644 --- a/src/main/java/buttondevteam/chat/formatting/ChatFormatter.java +++ b/src/main/java/buttondevteam/chat/formatting/ChatFormatter.java @@ -71,15 +71,18 @@ public final class ChatFormatter { // Set ending to -1 until closed with another 1 long "section" - only do this if IsRange is true final FormattedSection section = sections.get(i); if (!section.IsRange) { - escaped = section.Formatters.contains(ChatProcessing.ESCAPE_FORMATTER); + escaped = section.Formatters.contains(ChatProcessing.ESCAPE_FORMATTER) && !escaped; // Enable escaping on first \, disable on second combined.add(section); - continue; // TODO: Escape \ and check and fix escape logic + continue; } // TODO: Actually combine overlapping sections - if (nextSection.containsKey(section.Formatters.get(0)) && !escaped) { - FormattedSection s = nextSection.remove(section.Formatters.get(0)); - DebugCommand.SendDebugMessage("Finishing section: " + s); - s.End = section.Start; - combined.add(s); + if (nextSection.containsKey(section.Formatters.get(0))) { + if (!escaped) { + FormattedSection s = nextSection.remove(section.Formatters.get(0)); + s.End = section.Start; + combined.add(s); + DebugCommand.SendDebugMessage("Finished section: " + s); + } else + escaped = false; // Reset escaping if applied, like if we're at the '*' in '\*' } else { DebugCommand.SendDebugMessage("Adding next section: " + section); nextSection.put(section.Formatters.get(0), section);