From 7b9217cdffd1cbe97d6756d54842a04344a0aee3 Mon Sep 17 00:00:00 2001 From: Johannes Rieken Date: Wed, 6 Nov 2019 11:47:49 +0100 Subject: [PATCH] ignore declaration when references return only two results, #83752 --- src/vs/editor/contrib/gotoSymbol/goToSymbol.ts | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/src/vs/editor/contrib/gotoSymbol/goToSymbol.ts b/src/vs/editor/contrib/gotoSymbol/goToSymbol.ts index 5603b142eea90..05a509e7c8c97 100644 --- a/src/vs/editor/contrib/gotoSymbol/goToSymbol.ts +++ b/src/vs/editor/contrib/gotoSymbol/goToSymbol.ts @@ -59,8 +59,16 @@ export function getTypeDefinitionsAtPosition(model: ITextModel, position: Positi } export function getReferencesAtPosition(model: ITextModel, position: Position, token: CancellationToken): Promise { - return getLocationLinks(model, position, ReferenceProviderRegistry, (provider, model, position) => { - return provider.provideReferences(model, position, { includeDeclaration: true }, token); + return getLocationLinks(model, position, ReferenceProviderRegistry, async (provider, model, position) => { + const result = await provider.provideReferences(model, position, { includeDeclaration: true }, token); + if (!result || result.length !== 2) { + return result; + } + const resultWithoutDeclaration = await provider.provideReferences(model, position, { includeDeclaration: false }, token); + if (resultWithoutDeclaration && resultWithoutDeclaration.length === 1) { + return resultWithoutDeclaration; + } + return result; }); }