Limit prefix length

This commit is contained in:
sunarya-thito 2021-09-14 22:18:22 +07:00
parent 870720313c
commit 0fc8f36fe9

View File

@ -37,7 +37,8 @@ public class KeyCompletionProvider extends CompletionProvider<CompletionParamete
collect(map, instance.getTranslations().getNodes(), null, previewLocale, prefix); collect(map, instance.getTranslations().getNodes(), null, previewLocale, prefix);
Map<String, String> containedPath = new HashMap<>(); Map<String, String> containedPath = new HashMap<>();
StringBuilder prefixedKey = new StringBuilder(); StringBuilder prefixedKey = new StringBuilder();
while (containedPath.isEmpty()) { int maxPrefixLookUpLength = 5;
while (containedPath.isEmpty() && maxPrefixLookUpLength-- > 0) {
for (Map.Entry<String, String> e : map.entrySet()) { for (Map.Entry<String, String> e : map.entrySet()) {
if (e.getKey().startsWith(path)) { if (e.getKey().startsWith(path)) {
containedPath.put(e.getKey(), e.getValue()); containedPath.put(e.getKey(), e.getValue());