diff --git a/src/services/findAllReferences.ts b/src/services/findAllReferences.ts
index bf646fb717f..e742a7f1030 100644
--- a/src/services/findAllReferences.ts
+++ b/src/services/findAllReferences.ts
@@ -132,15 +132,8 @@ namespace ts.FindAllReferences {
const { node, name, kind, displayParts } = info;
const sourceFile = node.getSourceFile();
- return {
- containerKind: ScriptElementKind.unknown,
- containerName: "",
- fileName: sourceFile.fileName,
- kind,
- name,
- textSpan: createTextSpanFromNode(node, sourceFile),
- displayParts
- };
+ const textSpan = getTextSpan(isComputedPropertyName(node) ? node.expression : node, sourceFile);
+ return { containerKind: ScriptElementKind.unknown, containerName: "", fileName: sourceFile.fileName, kind, name, textSpan, displayParts };
}
function getDefinitionKindAndDisplayParts(symbol: Symbol, checker: TypeChecker, node: Node): { displayParts: SymbolDisplayPart[], kind: ScriptElementKind } {
@@ -218,8 +211,8 @@ namespace ts.FindAllReferences {
return { fileName, span };
}
- function getTextSpan(node: Node): TextSpan {
- let start = node.getStart();
+ function getTextSpan(node: Node, sourceFile?: SourceFile): TextSpan {
+ let start = node.getStart(sourceFile);
let end = node.getEnd();
if (node.kind === SyntaxKind.StringLiteral) {
start += 1;
diff --git a/tests/cases/fourslash/findAllRefsForComputedProperties.ts b/tests/cases/fourslash/findAllRefsForComputedProperties.ts
index 3df35cbfd76..5e11ec6f357 100644
--- a/tests/cases/fourslash/findAllRefsForComputedProperties.ts
+++ b/tests/cases/fourslash/findAllRefsForComputedProperties.ts
@@ -1,25 +1,24 @@
///
////interface I {
-//// [|["[|{| "isDefinition": true |}prop1|]"]|]: () => void;
+//// ["[|{| "isDefinition": true |}prop1|]"]: () => void;
////}
////
////class C implements I {
-//// [|["[|{| "isDefinition": true |}prop1|]"]|]: any;
+//// ["[|{| "isDefinition": true |}prop1|]"]: any;
////}
////
////var x: I = {
-//// [|["[|{| "isDefinition": true |}prop1|]"]|]: function () { },
+//// ["[|{| "isDefinition": true |}prop1|]"]: function () { },
////}
-// TODO: GH#22690
-const [r0Big, r0, r1Big, r1, r2Big, r2] = test.ranges();
+const [r0, r1, r2] = test.ranges();
verify.referenceGroups([r0, r1], [
- { definition: { text: '(property) I["prop1"]: () => void', range: r0Big }, ranges: [r0, r2] },
- { definition: { text: '(property) C["prop1"]: any', range: r1Big }, ranges: [r1] },
+ { definition: { text: '(property) I["prop1"]: () => void', range: r0 }, ranges: [r0, r2] },
+ { definition: { text: '(property) C["prop1"]: any', range: r1 }, ranges: [r1] },
]);
verify.referenceGroups(r2, [
- { definition: { text: '(property) I["prop1"]: () => void', range: r0Big }, ranges: [r0] },
- { definition: { text: '(property) C["prop1"]: any', range: r1Big }, ranges: [r1] },
- { definition: { text: '(property) ["prop1"]: () => void', range: r2Big }, ranges: [r2] },
+ { definition: { text: '(property) I["prop1"]: () => void', range: r0 }, ranges: [r0] },
+ { definition: { text: '(property) C["prop1"]: any', range: r1 }, ranges: [r1] },
+ { definition: { text: '(property) ["prop1"]: () => void', range: r2 }, ranges: [r2] },
]);
diff --git a/tests/cases/fourslash/findAllRefsForComputedProperties2.ts b/tests/cases/fourslash/findAllRefsForComputedProperties2.ts
index c38487d58d3..1461dc304a5 100644
--- a/tests/cases/fourslash/findAllRefsForComputedProperties2.ts
+++ b/tests/cases/fourslash/findAllRefsForComputedProperties2.ts
@@ -1,25 +1,24 @@
///
////interface I {
-//// [|[[|{| "isDefinition": true |}42|]]|](): void;
+//// [[|{| "isDefinition": true |}42|]](): void;
////}
////
////class C implements I {
-//// [|[[|{| "isDefinition": true |}42|]]|]: any;
+//// [[|{| "isDefinition": true |}42|]]: any;
////}
////
////var x: I = {
-//// [|["[|{| "isDefinition": true |}42|]"]|]: function () { }
+//// ["[|{| "isDefinition": true |}42|]"]: function () { }
////}
-// TODO: GH#22690
-const [r0Big, r0, r1Big, r1, r2Big, r2] = test.ranges();
+const [r0, r1, r2] = test.ranges();
verify.referenceGroups([r0, r1], [
- { definition: { text: '(method) I[42](): void', range: r0Big }, ranges: [r0, r2] },
- { definition: { text: '(property) C[42]: any', range: r1Big }, ranges: [r1] },
+ { definition: { text: '(method) I[42](): void', range: r0 }, ranges: [r0, r2] },
+ { definition: { text: '(property) C[42]: any', range: r1 }, ranges: [r1] },
]);
verify.referenceGroups(r2, [
- { definition: { text: '(method) I[42](): void', range: r0Big }, ranges: [r0] },
- { definition: { text: '(property) C[42]: any', range: r1Big }, ranges: [r1] },
- { definition: { text: '(property) ["42"]: () => void', range: r2Big }, ranges: [r2] },
+ { definition: { text: '(method) I[42](): void', range: r0 }, ranges: [r0] },
+ { definition: { text: '(property) C[42]: any', range: r1 }, ranges: [r1] },
+ { definition: { text: '(property) ["42"]: () => void', range: r2 }, ranges: [r2] },
]);