mirror of
https://github.com/SuspiciousActivity/ByteEdit.git
synced 2026-08-13 17:56:17 +00:00
Added a contains check to autocomplete
This commit is contained in:
1 parent
66cd1dbd3e
commit
64c153f5e9
2 files changed
+11
-1
No files matched your search
@@ -154,9 +154,11 @@ public abstract class AbstractCompletionProvider extends CompletionProviderBase
|
|||||||
String text = getAlreadyEnteredText(comp);
|
String text = getAlreadyEnteredText(comp);
|
||||||
if (text != null) {
|
if (text != null) {
|
||||||
int index = Collections.binarySearch(completions, text, comparator);
|
int index = Collections.binarySearch(completions, text, comparator);
|
||||||
|
boolean exactMatch = false;
|
||||||
if (index < 0) { // No exact match
|
if (index < 0) { // No exact match
|
||||||
index = -index - 1;
|
index = -index - 1;
|
||||||
} else {
|
} else {
|
||||||
|
exactMatch = true;
|
||||||
// If there are several overloads for the function being
|
// If there are several overloads for the function being
|
||||||
// completed, Collections.binarySearch() will return the index
|
// completed, Collections.binarySearch() will return the index
|
||||||
// of one of those overloads, but we must return all of them,
|
// of one of those overloads, but we must return all of them,
|
||||||
@@ -176,6 +178,13 @@ public abstract class AbstractCompletionProvider extends CompletionProviderBase
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if (!exactMatch) {
|
||||||
|
for (Completion c : completions) {
|
||||||
|
if (c.getInputText().contains(text) && !retVal.contains(c)) {
|
||||||
|
retVal.add(c);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
return retVal;
|
return retVal;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -748,7 +748,8 @@ public class AutoCompletion {
|
|||||||
}
|
}
|
||||||
final List<Completion> completions = provider.getCompletions(textComponent);
|
final List<Completion> completions = provider.getCompletions(textComponent);
|
||||||
int count = completions == null ? 0 : completions.size();
|
int count = completions == null ? 0 : completions.size();
|
||||||
if (count > 1 || (count == 1 && (isPopupVisible() || textLen == 0)) || (count == 1 && !getAutoCompleteSingleChoices())) {
|
if (count > 1 || (count == 1 && (isPopupVisible() || text.equals(completions.get(0).getInputText())))
|
||||||
|
|| (count == 1 && (isPopupVisible() || textLen == 0)) || (count == 1 && !getAutoCompleteSingleChoices())) {
|
||||||
if (popupWindow == null) {
|
if (popupWindow == null) {
|
||||||
popupWindow = new AutoCompletePopupWindow(parentWindow, this);
|
popupWindow = new AutoCompletePopupWindow(parentWindow, this);
|
||||||
popupWindowListener.install(popupWindow);
|
popupWindowListener.install(popupWindow);
|
||||||
|
|||||||
Reference in new issue
Block a user