diff --git a/src/compiler/core.ts b/src/compiler/core.ts index f94ac9a75c5..63c7fdd1076 100644 --- a/src/compiler/core.ts +++ b/src/compiler/core.ts @@ -1659,7 +1659,7 @@ namespace ts { } export function isRootedDiskPath(path: string) { - return getRootLength(path) !== 0; + return path && getRootLength(path) !== 0; } export function convertToRelativePath(absoluteOrRelativePath: string, basePath: string, getCanonicalFileName: (path: string) => string): string { diff --git a/src/server/editorServices.ts b/src/server/editorServices.ts index 22a025ae68f..1958c7e5d20 100644 --- a/src/server/editorServices.ts +++ b/src/server/editorServices.ts @@ -1191,7 +1191,8 @@ namespace ts.server { projectOptions.compileOnSave === undefined ? false : projectOptions.compileOnSave); this.addFilesToProjectAndUpdateGraph(project, projectOptions.files, fileNamePropertyReader, clientFileName, projectOptions.typeAcquisition, configFileErrors); - + this.addFilesToProjectAndUpdateGraph(project, project.getExternalFiles(), fileNamePropertyReader, clientFileName, projectOptions.typeAcquisition, configFileErrors); + project.watchConfigFile(project => this.onConfigChangedForConfiguredProject(project)); if (!sizeLimitExceeded) { this.watchConfigDirectoryForProject(project, projectOptions); @@ -1210,7 +1211,7 @@ namespace ts.server { } } - private addFilesToProjectAndUpdateGraph(project: ConfiguredProject | ExternalProject, files: T[], propertyReader: FilePropertyReader, clientFileName: string, typeAcquisition: TypeAcquisition, configFileErrors: ReadonlyArray): void { + private addFilesToProjectAndUpdateGraph(project: ConfiguredProject | ExternalProject, files: ReadonlyArray, propertyReader: FilePropertyReader, clientFileName: string, typeAcquisition: TypeAcquisition, configFileErrors: ReadonlyArray): void { let errors: Diagnostic[]; for (const f of files) { const rootFileName = propertyReader.getFileName(f); diff --git a/src/server/project.ts b/src/server/project.ts index 4fb5ef78d75..d588bae88ae 100644 --- a/src/server/project.ts +++ b/src/server/project.ts @@ -747,7 +747,8 @@ namespace ts.server { } // compute and return the difference const lastReportedFileNames = this.lastReportedFileNames; - const currentFiles = arrayToSet(this.getFileNames()); + const externalFiles = this.getExternalFiles().map(f => toNormalizedPath(f)); + const currentFiles = arrayToSet(this.getFileNames().concat(externalFiles)); const added: string[] = []; const removed: string[] = []; @@ -770,7 +771,8 @@ namespace ts.server { else { // unknown version - return everything const projectFileNames = this.getFileNames(); - this.lastReportedFileNames = arrayToSet(projectFileNames); + const externalFiles = this.getExternalFiles().map(f => toNormalizedPath(f)); + this.lastReportedFileNames = arrayToSet(projectFileNames.concat(externalFiles)); this.lastReportedVersion = this.projectStructureVersion; return { info, files: projectFileNames, projectErrors: this.getGlobalProjectErrors() }; } @@ -1085,6 +1087,9 @@ namespace ts.server { } catch (e) { this.projectService.logger.info(`A plugin threw an exception in getExternalFiles: ${e}`); + if (e.stack) { + this.projectService.logger.info(e.stack); + } } })); }