Skip to content

Commit 757a3ac

Browse files
authored
Port #48978 forward to the revised FAR code (#49267)
* Port #48978 forward to the revised FAR code The old regression test didn't catch the corresponding bug in the new code because it hit the fast path where there's only a single project. * Drop spurious non-null assertion
1 parent 46e5301 commit 757a3ac

5 files changed

+61
-3
lines changed

src/server/session.ts

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -379,8 +379,8 @@ namespace ts.server {
379379
// have started the other project searches from related symbols. Propagate the
380380
// correct results to all other projects.
381381

382-
const defaultProjectResults = perProjectResults.get(defaultProject)!;
383-
if (defaultProjectResults[0].references[0].isDefinition === undefined) {
382+
const defaultProjectResults = perProjectResults.get(defaultProject);
383+
if (defaultProjectResults?.[0].references[0]?.isDefinition === undefined) {
384384
// Clear all isDefinition properties
385385
perProjectResults.forEach(projectResults => {
386386
for (const referencedSymbol of projectResults) {
@@ -580,7 +580,6 @@ namespace ts.server {
580580

581581
return resultsMap;
582582

583-
// May enqueue to otherPositionQueue
584583
function searchPosition(project: Project, location: DocumentPosition): readonly TResult[] | undefined {
585584
const projectResults = getResultsForPosition(project, location);
586585
if (!projectResults) return undefined;
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
[]
2+
3+
[]
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
[
2+
{
3+
"definition": {
4+
"containerKind": "",
5+
"containerName": "",
6+
"fileName": "/a/a.ts",
7+
"kind": "var",
8+
"name": "hello",
9+
"textSpan": {
10+
"start": 56,
11+
"length": 5
12+
},
13+
"displayParts": [
14+
{
15+
"text": "\"hello\"",
16+
"kind": "stringLiteral"
17+
}
18+
]
19+
},
20+
"references": []
21+
}
22+
]
23+
24+
[]
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
/// <reference path="../fourslash.ts"/>
2+
3+
// @Filename: /a/tsconfig.json
4+
////{ "files": ["a.ts"] }
5+
6+
// @Filename: /a/a.ts
7+
/////// <reference path="../b/b.ts" />
8+
/////*1*/;
9+
10+
// @Filename: /b/tsconfig.json
11+
////{ "files": ["b.ts"] }
12+
13+
// @Filename: /b/b.ts
14+
/////*2*/;
15+
16+
verify.baselineFindAllReferences('1', '2')
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
/// <reference path="../fourslash.ts"/>
2+
3+
// @Filename: /a/tsconfig.json
4+
////{ "files": ["a.ts"] }
5+
6+
// @Filename: /a/a.ts
7+
/////// <reference path="../b/b.ts" />
8+
////const str: string = "hello/*1*/";
9+
10+
// @Filename: /b/tsconfig.json
11+
////{ "files": ["b.ts"] }
12+
13+
// @Filename: /b/b.ts
14+
////const str2: string = "hello/*2*/";
15+
16+
verify.baselineFindAllReferences('1', '2')

0 commit comments

Comments
 (0)