diff --git a/api/src/main/java/net/kyori/adventure/text/ComponentCompaction.java b/api/src/main/java/net/kyori/adventure/text/ComponentCompaction.java index 570324b74..a0300af28 100644 --- a/api/src/main/java/net/kyori/adventure/text/ComponentCompaction.java +++ b/api/src/main/java/net/kyori/adventure/text/ComponentCompaction.java @@ -31,8 +31,12 @@ import net.kyori.adventure.text.format.TextDecoration; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; +import org.jetbrains.annotations.VisibleForTesting; final class ComponentCompaction { + @VisibleForTesting + static final boolean SIMPLIFY_STYLE_FOR_BLANK_COMPONENTS = false; + private ComponentCompaction() { } @@ -182,6 +186,12 @@ private static boolean isBlank(final Component component) { * @return a new, simplified style */ private static @NotNull Style simplifyStyleForBlank(final @NotNull Style style, final @Nullable Style parentStyle) { + if (!SIMPLIFY_STYLE_FOR_BLANK_COMPONENTS) { + // todo: can this be fixed a better way? + // https://github.com/KyoriPowered/adventure/issues/849 + return style; + } + final Style.Builder builder = style.toBuilder(); // TextColor doesn't affect spaces, unless there is other decoration present diff --git a/api/src/test/java/net/kyori/adventure/text/ComponentCompactingTest.java b/api/src/test/java/net/kyori/adventure/text/ComponentCompactingTest.java index dd8cdd0f3..2cd8be6a4 100644 --- a/api/src/test/java/net/kyori/adventure/text/ComponentCompactingTest.java +++ b/api/src/test/java/net/kyori/adventure/text/ComponentCompactingTest.java @@ -32,6 +32,7 @@ import org.junit.jupiter.api.DynamicTest; import org.junit.jupiter.api.Test; import org.junit.jupiter.api.TestFactory; +import org.junit.jupiter.api.condition.DisabledIf; import static net.kyori.adventure.key.Key.key; import static net.kyori.adventure.text.Component.empty; @@ -317,6 +318,11 @@ void testJoinTextWithChildren() { assertEquals(expectedCompact, notCompact.compact()); } + private static boolean shouldSkipSimplifyingStyleForBlankComponents() { + return !ComponentCompaction.SIMPLIFY_STYLE_FOR_BLANK_COMPONENTS; + } + + @DisabledIf(value = "shouldSkipSimplifyingStyleForBlankComponents", disabledReason = "https://github.com/KyoriPowered/adventure/issues/849") // todo: can this be fixed a better way? @Test void testBlankStyleRemoval() { final String blank = " "; @@ -327,6 +333,7 @@ void testBlankStyleRemoval() { assertEquals(expectedCompact, notCompact.compact()); } + @DisabledIf(value = "shouldSkipSimplifyingStyleForBlankComponents", disabledReason = "https://github.com/KyoriPowered/adventure/issues/849") // todo: can this be fixed a better way? @Test void testBlankCompactionWithRemovableStyle() { final String blank = " "; @@ -339,6 +346,7 @@ void testBlankCompactionWithRemovableStyle() { assertEquals(expectedCompact, notCompact.compact()); } + @DisabledIf(value = "shouldSkipSimplifyingStyleForBlankComponents", disabledReason = "https://github.com/KyoriPowered/adventure/issues/849") // todo: can this be fixed a better way? @Test void testBlankCompactionWithManyStyle() { final String blank = " ";