Don't repeat suggestions for same symbol (#21140)

* Track seen module graphs so symbols from the same module aren't repeated
Add test case

* Track symbols instead of modules

* Don't show duplicate symbols in spell checker

Removes the declared location from the message. Since we don't show duplicates anymore it would be a bit misleading if we only show the location for the first declaration of the symbol
This commit is contained in:
Jake Leahy 2022-12-23 00:44:10 +11:00 • committed by GitHub
commit 18c115c8d0
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
5 changed files with 71 additions and 35 deletions

View file

@ -289,7 +289,7 @@ proc suggestField(c: PContext, s: PSym; f: PNode; info: TLineInfo; outputs: var
s.getQuality, pm, c.inTypeContext > 0, 0))
template wholeSymTab(cond, section: untyped) {.dirty.} =
for (item, scopeN, isLocal) in allSyms(c):
for (item, scopeN, isLocal) in uniqueSyms(c):
let it = item
var pm: PrefixMatch
if cond:
@ -362,7 +362,7 @@ proc suggestOperations(c: PContext, n, f: PNode, typ: PType, outputs: var Sugges
proc suggestEverything(c: PContext, n, f: PNode, outputs: var Suggestions) =
# do not produce too many symbols:
for (it, scopeN, isLocal) in allSyms(c):
for (it, scopeN, isLocal) in uniqueSyms(c):
var pm: PrefixMatch
if filterSym(it, f, pm):
outputs.add(symToSuggest(c.graph, it, isLocal = isLocal, ideSug, n.info,
@ -680,7 +680,7 @@ proc suggestSentinel*(c: PContext) =
inc(c.compilesContextId)
var outputs: Suggestions = @[]
# suggest everything:
for (it, scopeN, isLocal) in allSyms(c):
for (it, scopeN, isLocal) in uniqueSyms(c):
var pm: PrefixMatch
if filterSymNoOpr(it, nil, pm):
outputs.add(symToSuggest(c.graph, it, isLocal = isLocal, ideSug,