Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Component compacting does not fully compact #1018

Open
diogotcorreia opened this issue Dec 26, 2023 · 0 comments
Open

Component compacting does not fully compact #1018

diogotcorreia opened this issue Dec 26, 2023 · 0 comments

Comments

@diogotcorreia
Copy link

Given the following component, I have to compact it twice to get a fully compacted component.

Component.text()
    .content("")
    .color(NamedTextColor.GREEN)
    .append(
        Component.text()
            .decorate(TextDecoration.ITALIC),
        Component.text("consectetur adipiscing elit")
            .color(TextColor.color(0x123456))
    )
    .asComponent()

Without compacting:

{"color":"green","extra":[{"italic":true,"text":""},{"color":"#123456","text":"consectetur adipiscing elit"}],"text":""}

After compacting once:

{"color":"green","extra":[{"color":"#123456","text":"consectetur adipiscing elit"}],"text":""}

After compacting twice:

{"color":"#123456","text":"consectetur adipiscing elit"}

After compacting three times (does not change):

{"color":"#123456","text":"consectetur adipiscing elit"}

As you can see, the first time I compact the component, it does not fully compact.
I'm not sure if this is intended or not. I'm also unsure if this is related to #483.

As per my use-case, I'm using this in unit tests where I just care if the components are equivalent, so I just compact both the result and the expected component and see if they match - however, compacting once isn't working, I have to compact twice.

Note: In the examples above, the components were serialized to JSON with GsonComponentSerializer.gson().serialize(component).

I'm using Adventure 4.15.0.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants