diff --git a/plugin/src/main/java/me/filoghost/holographicdisplays/placeholder/parsing/StringWithPlaceholders.java b/plugin/src/main/java/me/filoghost/holographicdisplays/placeholder/parsing/StringWithPlaceholders.java index 37c1570b..24ea06ad 100644 --- a/plugin/src/main/java/me/filoghost/holographicdisplays/placeholder/parsing/StringWithPlaceholders.java +++ b/plugin/src/main/java/me/filoghost/holographicdisplays/placeholder/parsing/StringWithPlaceholders.java @@ -51,12 +51,11 @@ public class StringWithPlaceholders { if (replacement != null) { // Append placeholder replacement output.append(replacement); - lastAppendIndex = match.endIndex; } else { // If no replacement is provided, do not replace the occurrence output.append(match.unparsedString); } - + lastAppendIndex = match.endIndex; } // Append trailing text (if any) diff --git a/plugin/src/test/java/me/filoghost/holographicdisplays/placeholder/parsing/StringWithPlaceholdersTest.java b/plugin/src/test/java/me/filoghost/holographicdisplays/placeholder/parsing/StringWithPlaceholdersTest.java index d4029f51..9d089aa4 100644 --- a/plugin/src/test/java/me/filoghost/holographicdisplays/placeholder/parsing/StringWithPlaceholdersTest.java +++ b/plugin/src/test/java/me/filoghost/holographicdisplays/placeholder/parsing/StringWithPlaceholdersTest.java @@ -5,6 +5,7 @@ */ package me.filoghost.holographicdisplays.placeholder.parsing; +import org.junit.jupiter.api.Test; import org.junit.jupiter.params.ParameterizedTest; import org.junit.jupiter.params.provider.Arguments; import org.junit.jupiter.params.provider.MethodSource; @@ -33,6 +34,13 @@ class StringWithPlaceholdersTest { Arguments.of("abc p}", "abc p}") // Placeholder without opening tag ); } + + @Test + void skipReplacing() { + String input = "{p} a {p} b {p}"; + StringWithPlaceholders s = new StringWithPlaceholders(input); + assertThat(s.replacePlaceholders(occurrence -> null)).isEqualTo(input); + } @ParameterizedTest(name = "[{index}] {0} -> {1}, {2}, {3}") @MethodSource("parsingTestArguments")