Skip to content

Commit 385a673

Browse files
cmagliefacchinm
authored andcommitted
autocompletion: factored filtering of completions
1 parent 5e8895c commit 385a673

File tree

1 file changed

+9
-8
lines changed

1 file changed

+9
-8
lines changed

app/src/cc/arduino/autocomplete/ClangCompletionProvider.java

+9-8
Original file line numberDiff line numberDiff line change
@@ -115,7 +115,14 @@ protected List<Completion> getCompletionsImpl(JTextComponent textarea) {
115115
e.printStackTrace();
116116
return res;
117117
}
118+
119+
String enteredText = getAlreadyEnteredText(textarea);
120+
118121
for (ArduinoCompletion cc : allCc) {
122+
// Filter completions based on already entered text
123+
if (!cc.getCompletion().getTypedText().startsWith(enteredText)) {
124+
continue;
125+
}
119126

120127
if (cc.type.equals("Function")) {
121128
List<Parameter> params = new ArrayList<>();
@@ -135,10 +142,6 @@ protected List<Completion> getCompletionsImpl(JTextComponent textarea) {
135142
}
136143
fancyParameters += ")";
137144

138-
if (!cc.getCompletion().getTypedText().startsWith(getAlreadyEnteredText(textarea))) {
139-
continue;
140-
}
141-
142145
FunctionCompletion compl = new FunctionCompletion(this,
143146
cc.getCompletion().getTypedText(),
144147
cc.getCompletion().getResultType());
@@ -180,10 +183,8 @@ protected List<Completion> getCompletionsImpl(JTextComponent textarea) {
180183
}
181184
fancyParameters += ")";
182185
//System.out.println("TEMPLATE: " + template);
183-
if (typedText.startsWith(getAlreadyEnteredText(textarea))) {
184-
TemplateCompletion compl = new TemplateCompletion(this, typedText, fancyParameters + " : " + returnType , template);
185-
res.add(compl);
186-
}
186+
TemplateCompletion compl = new TemplateCompletion(this, typedText, fancyParameters + " : " + returnType , template);
187+
res.add(compl);
187188
}
188189
return res;
189190
} catch (Exception e) {

0 commit comments

Comments
 (0)