Skip to content
Permalink
Browse files

Do not filter out valid completion arguments

Fixes a bug introduced by PR 200. The bug related to the Values annotation which uses this getCompletionValues method also.

This is definitely not the propersolution. The underlying issue is
related to the logic calling `args` which is the original argument
array. And it should not be using arguments which have been resolved in
a previous parameter.
I was not able to find a quick/simple way to accommodate that issue.
  • Loading branch information...
chickeneer committed Jun 5, 2019
1 parent 4880a02 commit 7292c50f4a67c4b33ce3ed7b5e7ff0664601f15f
Showing with 6 additions and 5 deletions.
  1. +6 −5 core/src/main/java/co/aikar/commands/CommandCompletions.java
@@ -263,12 +263,13 @@ String findDefaultCompletion(RegisteredCommand cmd, String[] args) {
&& args.length > ACFPatterns.SPACE.split(command.complete).length) {
String start = String.join(" ", args);
completions = completions.stream()
.filter(s -> s != null && s.split(" ").length >= args.length)
.filter(s -> ApacheCommonsLangUtil.startsWithIgnoreCase(s, start))
.map(s -> {
String[] completionArgs = s.split(" ");
return String.join(" ",
Arrays.copyOfRange(completionArgs, args.length - 1, completionArgs.length));
if (s != null && s.split(" ").length >= args.length && ApacheCommonsLangUtil.startsWithIgnoreCase(s, start)) {
String[] completionArgs = s.split(" ");
return String.join(" ", Arrays.copyOfRange(completionArgs, args.length - 1, completionArgs.length));
} else {
return s;
}
}).collect(Collectors.toList());
}

0 comments on commit 7292c50

Please sign in to comment.
You can’t perform that action at this time.