SpongeAPI icon indicating copy to clipboard operation
SpongeAPI copied to clipboard

Wrapping command elements with empty usage at the end of seq generates extra whitespace in usage

Open thibaulthenry opened this issue 5 years ago • 2 comments

SpongeVanilla version: 1.12.2-7.3.0
Java version: 8
Operating System: Windows 10
Plugins: only my plugin in development (cosmos)

Hey,

Again a small ticket to inform that wrapping command elements with empty usage at the end of CommandElement#seq generates extra whitespace in command usage.

The problem occurs with GenericArguments#markTrue or GenericArguments#none and all elements with Text.EMPTY usage.

For example:

GenericArguments.seq(
    GenericArguments.string(Text.of("arg1")),
    GenericArguments.markTrue(Text.of("argTrue"))
 ),
GenericArguments.string(Text.of("arg2"))

will generates

Capture3

It's limited to one extra whitespace per seq element, but with (ok.. kind of strange) arguments wrapping, it accumulates :

GenericArguments.seq(
    GenericArguments.string(Text.of("arg1")),
    GenericArguments.seq(
        GenericArguments.string(Text.of("sub1")),
        GenericArguments.seq(
            GenericArguments.string(Text.of("subsub1")),
            GenericArguments.none()
        ),
        GenericArguments.none()
    ),
    GenericArguments.none()
),
GenericArguments.string(Text.of("arg2"))

will generates

Capture4

Thank you for reading this issue.

thibaulthenry avatar Nov 10 '20 19:11 thibaulthenry

Given how minor this issue is, the focus we have on getting our 1.15.2 builds completed and that the commands system has been completely rewritten for API 8 to support the client side completion, I will admit that it is very unlikely that I will look at this. However, I would welcome a PR to fix this if you have the inclination to do it.

dualspiral avatar Nov 14 '20 16:11 dualspiral

Totally agree, just wanted to write it down to not forget. I'll try to fix it on free time.

thibaulthenry avatar Nov 14 '20 16:11 thibaulthenry