Does not add a duplicate completion when offering an export which was re-declared as a global - fixes #32675

This commit is contained in:
Orta Therox
2019-10-16 17:02:35 -04:00
parent b7c85c7382
commit c40ddb183e
2 changed files with 40 additions and 3 deletions

View File

@@ -1000,6 +1000,7 @@ namespace ts.Completions {
let completionKind = CompletionKind.None;
let isNewIdentifierLocation = false;
let keywordFilters = KeywordCompletionFilters.None;
// This also gets mutated in nested-functions after the return
let symbols: Symbol[] = [];
const symbolToOriginInfoMap: SymbolOriginInfoMap = [];
const symbolToSortTextMap: SymbolSortTextMap = [];
@@ -1342,9 +1343,12 @@ namespace ts.Completions {
}
const symbolId = getSymbolId(symbol);
symbols.push(symbol);
symbolToOriginInfoMap[symbolId] = origin;
symbolToSortTextMap[symbolId] = SortText.AutoImportSuggestions;
const existingSymbol = findLast(symbols, symbol => symbol.id === symbolId);
if (!existingSymbol) {
symbols.push(symbol);
symbolToOriginInfoMap[symbolId] = origin;
symbolToSortTextMap[symbolId] = SortText.AutoImportSuggestions;
}
});
}
filterGlobalCompletion(symbols);