Skip to content

Commit

Permalink
Also compare full definition if matches
Browse files Browse the repository at this point in the history
  • Loading branch information
bangbangsheshotmedown authored Nov 10, 2024
1 parent 93fcbc8 commit 88f04e5
Showing 1 changed file with 22 additions and 2 deletions.
24 changes: 22 additions & 2 deletions src/dcd/server/autocomplete/complete.d
Original file line number Diff line number Diff line change
Expand Up @@ -592,7 +592,17 @@ void setCompletions(T)(ref AutocompleteResponse response,
{
if (sym.name !is null && sym.name.length > 0 && isPublicCompletionKind(sym.kind)
&& (p is null ? true : toUpper(sym.name.data).startsWith(toUpper(p)))
&& !r.completions.canFind!(a => a.identifier == sym.name && a.kind == sym.kind)
&& !r.completions.canFind!((a) {
// this filters out similar symbols
// this is needed because similar symbols can exist do to version conditionals
// fast check first, only compare full definition if it matches
bool same = a.identifier == sym.name && a.kind == sym.kind;
if (same) {
auto info = makeSymbolCompletionInfo(sym, sym.kind);
if (info.definition != a.definition) same = false;
}
return same;
})
&& sym.name[0] != '*'
&& mightBeRelevantInCompletionScope(sym, completionScope))
{
Expand All @@ -610,7 +620,17 @@ void setCompletions(T)(ref AutocompleteResponse response,
auto currentSymbols = completionScope.getSymbolsInCursorScope(cursorPosition);
foreach (s; currentSymbols.filter!(a => isPublicCompletionKind(a.kind)
&& toUpper(a.name.data).startsWith(toUpper(partial))
&& !response.completions.canFind!(r => r.identifier == a.name && r.kind == a.kind)
&& !response.completions.canFind!((r) {
// this filters out similar symbols
// this is needed because similar symbols can exist do to version conditionals
// fast check first, only compare full definition if it matches
bool same = (r.identifier == a.name && r.kind == a.kind);
if (same) {
auto info = makeSymbolCompletionInfo(a, a.kind);
if (info.definition != r.definition) same = false;
}
return same;
})
&& mightBeRelevantInCompletionScope(a, completionScope)))
{
response.completions ~= makeSymbolCompletionInfo(s, s.kind);
Expand Down

0 comments on commit 88f04e5

Please sign in to comment.