Skip to content

Commit

Permalink
Fix tab completions for variable-length arguments
Browse files Browse the repository at this point in the history
  • Loading branch information
boxbeam committed Aug 16, 2022
1 parent 33ea760 commit b94772f
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -70,10 +70,10 @@ public CommandResult<T> parse(CommandContext<T> context) {

@Override
public CommandResult<T> complete(CommandContext<T> context, Set<String> completions) {
parse(context);
if (context.getArguments().size() == 1) {
completions.addAll(getType().complete(context, context.peekArg().getValue()));
}
parse(context);
return success();
}

Expand Down
2 changes: 1 addition & 1 deletion test/res/ordinate-test.ordn
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ consuming string...:arg {
optionalConsuming string...:arg? {
hook
}
vararg int[]:nums {
vararg boolean[]:bools {
hook
}
optionalVararg int[]:nums? {
Expand Down
3 changes: 2 additions & 1 deletion test/src/redempt/ordinate/test/OrdinateTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -114,10 +114,11 @@ public void consumingTest() {

@Test
public void varargTest() {
tester.expect("vararg 1 2 3", Arrays.asList(1, 2, 3));
tester.expect("vararg true false true", Arrays.asList(true, false, true));
tester.expectFailure("vararg");
tester.expect("optionalVararg 1 2 3", Arrays.asList(1, 2, 3));
tester.expect("optionalVararg", Collections.emptyList());
tester.expectCompletions("vararg ", "true", "false");
}

}

0 comments on commit b94772f

Please sign in to comment.