From f016cabac006a324ef3402b1964d7c0127697890 Mon Sep 17 00:00:00 2001 From: Vitaly Turovsky Date: Sun, 11 Sep 2022 09:04:03 +0300 Subject: [PATCH] feat: -big annoyance, meet `removeDefinitionFromReferences`! Thanks, talk2much! --- src/configurationType.ts | 5 +++++ typescript/src/index.ts | 8 ++++++++ 2 files changed, 13 insertions(+) diff --git a/src/configurationType.ts b/src/configurationType.ts index d9721ded..7d7e0e7e 100644 --- a/src/configurationType.ts +++ b/src/configurationType.ts @@ -136,4 +136,9 @@ export type Configuration = { * @default [] */ replaceSuggestions: ReplaceRule[] + /** + * https://github.com/microsoft/vscode/issues/160637 + * @default true + */ + removeDefinitionFromReferences: boolean } diff --git a/typescript/src/index.ts b/typescript/src/index.ts index daffe465..deafb74b 100644 --- a/typescript/src/index.ts +++ b/typescript/src/index.ts @@ -140,6 +140,14 @@ export = function ({ typescript }: { typescript: typeof import('typescript/lib/t return prior } + proxy.findReferences = (fileName, position) => { + let prior = info.languageService.findReferences(fileName, position) + if (prior && c('removeDefinitionFromReferences')) { + prior = prior.map(({ references, ...other }) => ({ ...other, references: references.filter(({ isDefinition }) => !isDefinition) })) + } + return prior + } + info.languageService[thisPluginMarker] = true return proxy