Also compare full definition if matches

This commit is contained in:
bangbangsheshotmedown 2024-11-10 20:17:29 +00:00 committed by GitHub
parent 93fcbc827b
commit 88f04e5d16
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
1 changed files with 22 additions and 2 deletions

View File

@ -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))
{
@ -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);