diff --git a/src/compiler/core.ts b/src/compiler/core.ts index f5e2a4069e4..84321b4b624 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 3f5b76ae39d..3830a85917e 100644 --- a/src/server/editorServices.ts +++ b/src/server/editorServices.ts @@ -1190,7 +1190,8 @@ namespace ts.server { /*languageServiceEnabled*/ !sizeLimitExceeded, projectOptions.compileOnSave === undefined ? false : projectOptions.compileOnSave); - this.addFilesToProjectAndUpdateGraph(project, projectOptions.files, fileNamePropertyReader, clientFileName, projectOptions.typeAcquisition, configFileErrors); + const filesToAdd = projectOptions.files.concat(project.getExternalFiles()); + this.addFilesToProjectAndUpdateGraph(project, filesToAdd, fileNamePropertyReader, clientFileName, projectOptions.typeAcquisition, configFileErrors); project.watchConfigFile(project => this.onConfigChangedForConfiguredProject(project)); if (!sizeLimitExceeded) { @@ -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 8d8d33ddd16..9ef79530e51 100644 --- a/src/server/project.ts +++ b/src/server/project.ts @@ -746,7 +746,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[] = []; @@ -769,7 +770,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() }; } @@ -1084,6 +1086,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); + } } })); }