Tab completion for first argument does not work correctly using SimpleCommand
Nobody has claimed this yet.
- Dominant language
- Java
- Stars
- 2.3k
- Forks
- 959
- Avg merge
- 5d 10h
- Merged PRs (30d)
- 2
Description
Hello Velocity-Team,
I just migrated from waterfall to Velocity 3.3.0-SNAPSHOT-b389 and found that the first argument of an SimpleCommand isn't tab-completed correctly after I rewrote my plugins commands from waterfall to velocity.
In my command I used the following code to check what's the cause.
@Override
public CompletableFuture<List<String>> suggestAsync(Invocation invocation)
{
CommandSource sender = invocation.source();
String label = invocation.alias();
String[] args = invocation.arguments();
System.out.println("COMMAND | " + sender + " | " + label + " | " + String.join(", ", args) + " | " + args.length);
if(args.length == 1)
// tab completion here
}
I got these outputs:
Input: /mycommand (note the space at the end)
Output: COMMAND | [connected player] EvilJavaSkill (/ip) | mycommand | | 0
Input: /mycommand E
Output: COMMAND | [connected player] EvilJavaSkill (/ip) | mycommand | E | 1
Input: /mycommand (note the 2 spaces at the end)
Output: COMMAND | [connected player] EvilJavaSkill (/ip) | mycommand | , | 2
Inputting two spaces sets the args.length to 2 (output nr. 3) but inputting only one does set it to 0 (output nr. 1). The player has to enter a character first before the args length says that the player is trying to tab-complete the first argument.
In my code I check for an args.length equals 1 to make sure the player is tab-completing the first argument. But somehow when the player hasn't entered any letter no tab-completion will be done due to invocation.arguments(); returning an empty array. I would say that invocation.arguments(); should return an array with an empty string in it.
I consider this is a bug if there is no special reason why velocity does not provide an array length of 1.
If there are any questions, let me know and I will help as much as I can.
Kind regards
EvilJavaSkill
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by tracing the command suggestion path around Invocation.arguments() and SimpleCommand, using the reported inputs /mycommand , /mycommand E, and /mycommand to reproduce the differing argument arrays. Done means first-argument completion receives a consistent representation when the command ends with one space, with regression coverage for the reported cases.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- java
- Domain
- api, cli
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 45/100