From 7292c50f4a67c4b33ce3ed7b5e7ff0664601f15f Mon Sep 17 00:00:00 2001 From: chickeneer Date: Wed, 5 Jun 2019 11:20:10 -0500 Subject: [PATCH] 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. --- .../java/co/aikar/commands/CommandCompletions.java | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/core/src/main/java/co/aikar/commands/CommandCompletions.java b/core/src/main/java/co/aikar/commands/CommandCompletions.java index ebf5fe0b..6d248255 100644 --- a/core/src/main/java/co/aikar/commands/CommandCompletions.java +++ b/core/src/main/java/co/aikar/commands/CommandCompletions.java @@ -263,12 +263,13 @@ public class CommandCompletions { && 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()); }