Skip to content

Command element completion does not work with spaced-texts wrapped in quotes #2256

@thibaulthenry

Description

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

Hey, it's me (again) for another issue 😅

I already spoke about it in Discord but I found an issue using quotes for commands in Sponge.

For example, I have this command following command structure that gives me the choice between two strings containing spaces :

commandArguments = [

    GenericArguments.choices(
        Text.of("arg1"),
        () -> Arrays.asList("\"Text with spaces\"", "\"Another string\"" ),
        (key) -> "ignored value"
    ),

    GenericArguments.bool(Text.of("arg2"))
]

As you can see, I escape quotes so when a user types the command, it would result in something like this :

/testcommand "Text with spaces" false

  • Problem 1 is :

When the user press tab multiple times, the choices should be displayed in turns, one by one, but in fact the completion restarts each time tab is pressed at the last space. For example :

Typing /testcommand
Pressing tab once and get /testcommand "Text with spaces"
Pressing tab again and get /testcommand "Text with "Another string"
Pressing tab again and get /testcommand "Text with "Another "Text with spaces"
Pressing tab again and get /testcommand "Text with "Another "Text with "Another string"

over and over... it never stops

  • Problem 2 is :

When the choices element is filled with text that start with similar sub text, the completion just stops. For example with this following command structure :

commandArguments = [

    GenericArguments.choices(
        Text.of("arg1"),
        () -> Arrays.asList("\"Text with spaces\"", "\"Text with something\"" ),
        (key) -> "ignored value"
    ),

    GenericArguments.bool(Text.of("arg2"))
]

Typing /testcommand
Pressing tab once and get /testcommand "Text with
Here it stops at the end of the longest common prefix, which is totally normal and expected

However, when user press tab again, nothing is filled anymore.
We expect that the command would be filled with the remainings text after the longest common prefix, in this case : spaces" or something".

I guess that the completion broke because of the space after Text with.

Do not hesitate to ask me for more information or more tests, I'm ready to help.
Thank you for reading this issue.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions