Skip to content

Commit

Permalink
Improve the behavior of SuggestionProvider.compose
Browse files Browse the repository at this point in the history
  • Loading branch information
Revxrsal committed Oct 12, 2022
1 parent 451c6d6 commit 75e80f3
Showing 1 changed file with 3 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,9 @@ Collection<String> getSuggestions(@NotNull List<String> args,
@Contract("null -> this; !null -> new")
default SuggestionProvider compose(@Nullable SuggestionProvider other) {
if (other == null) return this;
if (this == EMPTY && other == EMPTY) return EMPTY;
if (other == EMPTY) return this;
if (this == EMPTY) return other;
return (args, sender, command) -> {
Set<String> completions = new HashSet<>(other.getSuggestions(args, sender, command));
completions.addAll(getSuggestions(args, sender, command));
Expand Down

0 comments on commit 75e80f3

Please sign in to comment.