mirror of
https://github.com/LuckPerms/LuckPerms.git
synced 2024-11-28 05:35:26 +01:00
Use contains instead of startsWith for context tab completions
This commit is contained in:
parent
d5ac45d230
commit
4a049ca732
@ -49,6 +49,18 @@ public interface CompletionSupplier {
|
|||||||
return partial -> stringsSupplier.get().filter(TabCompleter.startsWithIgnoreCase(partial)).collect(Collectors.toList());
|
return partial -> stringsSupplier.get().filter(TabCompleter.startsWithIgnoreCase(partial)).collect(Collectors.toList());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static CompletionSupplier contains(String... strings) {
|
||||||
|
return contains(() -> Arrays.stream(strings));
|
||||||
|
}
|
||||||
|
|
||||||
|
static CompletionSupplier contains(Collection<String> strings) {
|
||||||
|
return contains(strings::stream);
|
||||||
|
}
|
||||||
|
|
||||||
|
static CompletionSupplier contains(Supplier<Stream<String>> stringsSupplier) {
|
||||||
|
return partial -> stringsSupplier.get().filter(TabCompleter.containsIgnoreCase(partial)).collect(Collectors.toList());
|
||||||
|
}
|
||||||
|
|
||||||
List<String> supplyCompletions(String partial);
|
List<String> supplyCompletions(String partial);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -107,4 +107,13 @@ public class TabCompleter {
|
|||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static Predicate<String> containsIgnoreCase(String substring) {
|
||||||
|
return string -> {
|
||||||
|
if (string.length() < substring.length()) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
return string.toLowerCase().contains(substring.toLowerCase());
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -99,7 +99,7 @@ public final class TabCompletions {
|
|||||||
int index = partial.indexOf('=');
|
int index = partial.indexOf('=');
|
||||||
if (index == -1) {
|
if (index == -1) {
|
||||||
// cursor is specifying the key
|
// cursor is specifying the key
|
||||||
return CompletionSupplier.startsWith(potentialContexts.toMap().keySet()).supplyCompletions(partial);
|
return CompletionSupplier.contains(potentialContexts.toMap().keySet()).supplyCompletions(partial);
|
||||||
}
|
}
|
||||||
|
|
||||||
// cursor is specifying the value
|
// cursor is specifying the value
|
||||||
|
Loading…
Reference in New Issue
Block a user