Don't show reference code lens for both class and ctor in es5 classes
Fixes #90396
This commit is contained in:
parent
5c017be321
commit
8503705b11
|
@ -99,6 +99,14 @@ export class TypeScriptReferencesCodeLensProvider extends TypeScriptBaseCodeLens
|
||||||
case PConst.Kind.memberSetAccessor:
|
case PConst.Kind.memberSetAccessor:
|
||||||
case PConst.Kind.constructorImplementation:
|
case PConst.Kind.constructorImplementation:
|
||||||
case PConst.Kind.memberVariable:
|
case PConst.Kind.memberVariable:
|
||||||
|
// Don't show if child and parent have same start
|
||||||
|
// For https://github.com/microsoft/vscode/issues/90396
|
||||||
|
if (parent &&
|
||||||
|
typeConverters.Position.fromLocation(parent.spans[0].start).isEqual(typeConverters.Position.fromLocation(item.spans[0].start))
|
||||||
|
) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
// Only show if parent is a class type object (not a literal)
|
// Only show if parent is a class type object (not a literal)
|
||||||
switch (parent?.kind) {
|
switch (parent?.kind) {
|
||||||
case PConst.Kind.class:
|
case PConst.Kind.class:
|
||||||
|
|
|
@ -91,6 +91,19 @@ suite('TypeScript References', () => {
|
||||||
const codeLenses = await getCodeLenses(testDocumentUri);
|
const codeLenses = await getCodeLenses(testDocumentUri);
|
||||||
assert.strictEqual(codeLenses?.length, 0);
|
assert.strictEqual(codeLenses?.length, 0);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
test('Should not show duplicate references on ES5 class (https://github.com/microsoft/vscode/issues/90396)', async () => {
|
||||||
|
const testDocumentUri = vscode.Uri.parse('untitled:test3.js');
|
||||||
|
await createTestEditor(testDocumentUri,
|
||||||
|
`function A() {`,
|
||||||
|
` console.log("hi");`,
|
||||||
|
`}`,
|
||||||
|
`A.x = {};`,
|
||||||
|
);
|
||||||
|
|
||||||
|
const codeLenses = await getCodeLenses(testDocumentUri);
|
||||||
|
assert.strictEqual(codeLenses?.length, 1);
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
function getCodeLenses(document: vscode.Uri): Thenable<readonly vscode.CodeLens[] | undefined> {
|
function getCodeLenses(document: vscode.Uri): Thenable<readonly vscode.CodeLens[] | undefined> {
|
||||||
|
|
Loading…
Reference in a new issue