From b9ea3471a404339fa09a0cd4170889fc321d66bd Mon Sep 17 00:00:00 2001 From: Benjamin Lichtman Date: Thu, 28 Dec 2017 11:22:41 -0800 Subject: [PATCH] Simplify test and add explanatory assertion --- src/harness/unittests/tsserverProjectSystem.ts | 6 +----- src/server/editorServices.ts | 1 + 2 files changed, 2 insertions(+), 5 deletions(-) diff --git a/src/harness/unittests/tsserverProjectSystem.ts b/src/harness/unittests/tsserverProjectSystem.ts index 438575917c8..34c8f9e9656 100644 --- a/src/harness/unittests/tsserverProjectSystem.ts +++ b/src/harness/unittests/tsserverProjectSystem.ts @@ -1185,13 +1185,9 @@ namespace ts.projectSystem { }); it("external project for dynamic file", () => { - const file1 = { - path: "/a/b/f1.ts", - content: "let x =1;" - }; const externalProjectName = "^ScriptDocument1 file1.ts"; const externalFiles = toExternalFiles(["^ScriptDocument1 file1.ts"]); - const host = createServerHost([file1]); + const host = createServerHost([]); const projectService = createProjectService(host); projectService.openExternalProject({ rootFiles: externalFiles, diff --git a/src/server/editorServices.ts b/src/server/editorServices.ts index 0110e88f773..664938a4cdc 100644 --- a/src/server/editorServices.ts +++ b/src/server/editorServices.ts @@ -1779,6 +1779,7 @@ namespace ts.server { const isDynamic = isDynamicFileName(fileName); Debug.assert(isRootedDiskPath(fileName) || isDynamic || openedByClient, "Script info with non-dynamic relative file name can only be open script info"); Debug.assert(!isRootedDiskPath(fileName) || this.currentDirectory === currentDirectory || !this.openFilesWithNonRootedDiskPath.has(this.toCanonicalFileName(fileName)), "Open script files with non rooted disk path opened with current directory context cannot have same canonical names"); + Debug.assert(!isDynamic || this.currentDirectory === currentDirectory, "Dynamic files must always have current directory context since containing external project name will always match the script info name."); // If the file is not opened by client and the file doesnot exist on the disk, return if (!openedByClient && !isDynamic && !(hostToQueryFileExistsOn || this.host).fileExists(fileName)) { return;