Skip to content
This repository was archived by the owner on Jun 7, 2022. It is now read-only.

Commit 343dab7

Browse files
authored
Drop fuzzy results from files that have LSIF results (#291)
1 parent b3c1124 commit 343dab7

File tree

1 file changed

+11
-1
lines changed

1 file changed

+11
-1
lines changed

src/extension/extension.ts

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -614,9 +614,19 @@ export async function activate(ctx: sourcegraph.ExtensionContext): Promise<void>
614614
}
615615

616616
if (!config.value['typescript.serverUrl']) {
617+
// Gets an opaque value that is the same for all locations
618+
// within a file but different from other files.
619+
const file = (loc: sourcegraph.Location) => `${loc.uri.host} ${loc.uri.pathname} ${loc.uri.hash}`
620+
617621
const lsifReferences = await lsif.references(textDocument, position)
618622
const fuzzyReferences = (await basicCodeIntel.references(textDocument, position)) || []
619-
yield [...(lsifReferences === undefined ? [] : lsifReferences.value), ...fuzzyReferences]
623+
624+
const lsifFiles = new Set((lsifReferences ? lsifReferences.value : []).map(file))
625+
626+
yield [
627+
...(lsifReferences === undefined ? [] : lsifReferences.value),
628+
...fuzzyReferences.filter(fuzzyRef => !lsifFiles.has(file(fuzzyRef))),
629+
]
620630
} else {
621631
const textDocumentUri = new URL(textDocument.uri)
622632
const serverRootUri = resolveServerRootUri(textDocumentUri, serverSgEndpoint)

0 commit comments

Comments
 (0)