Skip to content

Commit 17f0cce

Browse files
author
zhengbli
committed
Update comments
1 parent 7741ec0 commit 17f0cce

2 files changed

Lines changed: 11 additions & 8 deletions

File tree

src/compiler/sys.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -398,8 +398,8 @@ namespace ts {
398398
// and https://github.com/Microsoft/TypeScript/issues/4643), therefore
399399
// if the current node.js version is newer than 4, use `fs.watch` instead.
400400
if (isNode4OrLater()) {
401-
// Note: in node the callback of fs.watch is given only the base file name as a parameter
402-
return _fs.watch(fileName, (eventName: string, baseFileName: string) => callback(fileName));
401+
// Note: in node the callback of fs.watch is given only the relative file name as a parameter
402+
return _fs.watch(fileName, (eventName: string, relativeFileName: string) => callback(fileName));
403403
}
404404

405405
var watchedFile = watchedFileSet.addFile(fileName, callback);

src/server/editorServices.ts

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -543,7 +543,7 @@ namespace ts.server {
543543
}
544544

545545
/**
546-
* This is the callback function when a watched directory has added or removed files.
546+
* This is the callback function when a watched directory has added or removed source code files.
547547
* @param project the project that associates with this directory watcher
548548
* @param fileName the absolute file name that changed in watched directory
549549
*/
@@ -567,12 +567,15 @@ namespace ts.server {
567567
// just update the current project.
568568
this.updateConfiguredProject(project);
569569

570-
// Call updateProjectStructure to clean up inferred projects we may have created for the
571-
// new files
570+
// Call updateProjectStructure to clean up inferred projects we may have
571+
// created for the new files
572572
this.updateProjectStructure();
573573
}
574574
}
575575

576+
/**
577+
* This is the callback function when a watched directory has an added tsconfig file.
578+
*/
576579
directoryWatchedForTsconfigChanged(fileName: string) {
577580
if (ts.getBaseFileName(fileName) != "tsconfig.json") {
578581
this.log(fileName + " is not tsconfig.json");
@@ -585,6 +588,8 @@ namespace ts.server {
585588
let rootFilesInTsconfig = projectOptions.files.map(f => this.getCanonicalFileName(f));
586589
let openFileRoots = this.openFileRoots.map(s => this.getCanonicalFileName(s.fileName));
587590

591+
// We should only care about the new tsconfig file if it contains any
592+
// opened root files of existing inferred projects
588593
for (let openFileRoot of openFileRoots) {
589594
if (rootFilesInTsconfig.indexOf(openFileRoot) >= 0) {
590595
this.reloadProjects();
@@ -708,6 +713,7 @@ namespace ts.server {
708713
}
709714
else {
710715
for (let directory of project.directoriesWatchedForTsconfig) {
716+
// if the ref count for this directory watcher drops to 0, it's time to close it
711717
if (!(--project.projectService.directoryWatchersRefCount[directory])) {
712718
this.log("Close directory watcher for: " + directory);
713719
project.projectService.directoryWatchersForTsconfig[directory].close();
@@ -956,9 +962,6 @@ namespace ts.server {
956962
this.addOpenFile(unattachedOpenFiles[i]);
957963
}
958964
this.printProjects();
959-
960-
this.log("Current openFileRoots: " + this.openFileRoots.map(s => s.fileName).toString());
961-
this.log("Current openFileRootsConfigured: " + this.openFileRootsConfigured.map(s => s.fileName).toString());
962965
}
963966

964967
getScriptInfo(filename: string) {

0 commit comments

Comments
 (0)