Handle the case where the FAR results map is empty (#49254)

* Handle the case where the FAR results map is empty

Searching exactly one project does not imply the presence of exactly one references list.

Fixes #49217

* Use emptyArray

Co-authored-by: Sheetal Nandi <shkamat@microsoft.com>

Co-authored-by: Sheetal Nandi <shkamat@microsoft.com>
This commit is contained in:
Andrew Casey
2022-05-26 11:00:28 -07:00
committed by GitHub
co-authored by Sheetal Nandi
parent 77ffb96b1a
commit 84974838c7
7 changed files with 40 additions and 2 deletions
+1 -2
View File
@@ -575,8 +575,7 @@ namespace ts.server {
// it easier for the caller to skip post-processing.
if (searchedProjects.size === 1) {
const it = resultsMap.values().next();
Debug.assert(!it.done);
return it.value;
return it.done ? emptyArray : it.value; // There may not be any results at all
}
return resultsMap;
@@ -0,0 +1 @@
[]
@@ -0,0 +1 @@
[]
@@ -0,0 +1,22 @@
[
{
"definition": {
"containerKind": "",
"containerName": "",
"fileName": "/tests/cases/fourslash/server/referencesToStringLiteralValue.ts",
"kind": "var",
"name": "some string",
"textSpan": {
"start": 19,
"length": 12
},
"displayParts": [
{
"text": "\"some string\"",
"kind": "stringLiteral"
}
]
},
"references": []
}
]
@@ -0,0 +1,5 @@
/// <reference path='fourslash.ts'/>
////const obj = {}/*1*/;
verify.baselineFindAllReferences('1');
@@ -0,0 +1,5 @@
/// <reference path='fourslash.ts'/>
/////*1*/
verify.baselineFindAllReferences('1');
@@ -0,0 +1,5 @@
/// <reference path='fourslash.ts'/>
////const s: string = "some /*1*/ string";
verify.baselineFindAllReferences('1');