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

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

Open
thibaulthenry opened this issue Nov 14, 2020 · 1 comment
Labels

Comments

@thibaulthenry
Copy link
Contributor

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.

@dualspiral dualspiral added the api: 7 (u) version: 1.12 label Nov 14, 2020
@dualspiral
Copy link
Contributor

dualspiral commented Nov 14, 2020

Similar to #2254, I don't see this as something we're really going to look at - though less minor than that issue, I don't see this as a major bug and with the way API 7's commands work, I feel like this would be a complicated fix for little gain. I may get time to look at it but I have many other foci right now that the time spent fixing this will far eclipse the value.

Again, you're welcome to investigate yourself and provide a PR if you feel up to it!

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

No branches or pull requests

2 participants