Fix the getCanonicalFileName in sys.ts and also check null value in file watcher call back
This commit is contained in:
parent
efc573f263
commit
c2f453b8fb
2 changed files with 12 additions and 4 deletions
|
@ -378,7 +378,11 @@ namespace ts {
|
||||||
*/
|
*/
|
||||||
function fileEventHandler(eventName: string, relativefileName: string, baseDirPath: Path) {
|
function fileEventHandler(eventName: string, relativefileName: string, baseDirPath: Path) {
|
||||||
// When files are deleted from disk, the triggered "rename" event would have a relativefileName of "undefined"
|
// When files are deleted from disk, the triggered "rename" event would have a relativefileName of "undefined"
|
||||||
const filePath = relativefileName === undefined ? undefined : toPath(relativefileName, baseDirPath, getCanonicalPath);
|
/* tslint:disable:no-null */
|
||||||
|
const filePath = relativefileName === undefined || relativefileName === null
|
||||||
|
? undefined
|
||||||
|
: toPath(relativefileName, baseDirPath, createGetCanonicalFileName(sys.useCaseSensitiveFileNames));
|
||||||
|
/* tslint:enable:no-null */
|
||||||
if (eventName === "change" && fileWatcherCallbacks.contains(filePath)) {
|
if (eventName === "change" && fileWatcherCallbacks.contains(filePath)) {
|
||||||
for (const fileCallback of fileWatcherCallbacks.get(filePath)) {
|
for (const fileCallback of fileWatcherCallbacks.get(filePath)) {
|
||||||
fileCallback(filePath);
|
fileCallback(filePath);
|
||||||
|
@ -460,7 +464,7 @@ namespace ts {
|
||||||
}
|
}
|
||||||
|
|
||||||
function getCanonicalPath(path: string): string {
|
function getCanonicalPath(path: string): string {
|
||||||
return useCaseSensitiveFileNames ? path.toLowerCase() : path;
|
return useCaseSensitiveFileNames ? path : path.toLowerCase();
|
||||||
}
|
}
|
||||||
|
|
||||||
function readDirectory(path: string, extension?: string, exclude?: string[]): string[] {
|
function readDirectory(path: string, extension?: string, exclude?: string[]): string[] {
|
||||||
|
|
|
@ -1002,7 +1002,9 @@ namespace ts.server {
|
||||||
info.setFormatOptions(this.getFormatCodeOptions());
|
info.setFormatOptions(this.getFormatCodeOptions());
|
||||||
this.filenameToScriptInfo[fileName] = info;
|
this.filenameToScriptInfo[fileName] = info;
|
||||||
if (!info.isOpen) {
|
if (!info.isOpen) {
|
||||||
info.fileWatcher = this.host.watchFile(<Path>fileName, _ => { this.watchedFileChanged(fileName); });
|
info.fileWatcher = this.host.watchFile(
|
||||||
|
toPath(fileName, fileName, createGetCanonicalFileName(sys.useCaseSensitiveFileNames)),
|
||||||
|
_ => { this.watchedFileChanged(fileName); });
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1215,7 +1217,9 @@ namespace ts.server {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
project.finishGraph();
|
project.finishGraph();
|
||||||
project.projectFileWatcher = this.host.watchFile(<Path>configFilename, _ => this.watchedProjectConfigFileChanged(project));
|
project.projectFileWatcher = this.host.watchFile(
|
||||||
|
toPath(configFilename, configFilename, createGetCanonicalFileName(sys.useCaseSensitiveFileNames)),
|
||||||
|
_ => this.watchedProjectConfigFileChanged(project));
|
||||||
this.log("Add recursive watcher for: " + ts.getDirectoryPath(configFilename));
|
this.log("Add recursive watcher for: " + ts.getDirectoryPath(configFilename));
|
||||||
project.directoryWatcher = this.host.watchDirectory(
|
project.directoryWatcher = this.host.watchDirectory(
|
||||||
ts.getDirectoryPath(configFilename),
|
ts.getDirectoryPath(configFilename),
|
||||||
|
|
Loading…
Reference in a new issue