Skip to content

Commit 0ec6eda

Browse files
committed
Merge pull request #2504 from Microsoft/fixConfigLookup
Fix bug stemming from use of tsc findConfigFile by server.
2 parents 631a9d8 + 237225b commit 0ec6eda

File tree

1 file changed

+27
-1
lines changed

1 file changed

+27
-1
lines changed

src/server/editorServices.ts

Lines changed: 27 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -764,14 +764,40 @@ module ts.server {
764764
return info;
765765
}
766766

767+
// This is different from the method the compiler uses because
768+
// the compiler can assume it will always start searching in the
769+
// current directory (the directory in which tsc was invoked).
770+
// The server must start searching from the directory containing
771+
// the newly opened file.
772+
findConfigFile(searchPath: string): string {
773+
while (true) {
774+
var fileName = ts.combinePaths(searchPath, "tsconfig.json");
775+
if (sys.fileExists(fileName)) {
776+
return fileName;
777+
}
778+
var parentPath = ts.getDirectoryPath(searchPath);
779+
if (parentPath === searchPath) {
780+
break;
781+
}
782+
searchPath = parentPath;
783+
}
784+
return undefined;
785+
}
786+
767787
/**
768788
* Open file whose contents is managed by the client
769789
* @param filename is absolute pathname
770790
*/
771791

772792
openClientFile(fileName: string) {
773793
var searchPath = ts.normalizePath(getDirectoryPath(fileName));
774-
var configFileName = ts.findConfigFile(searchPath);
794+
this.log("Search path: " + searchPath,"Info");
795+
var configFileName = this.findConfigFile(searchPath);
796+
if (configFileName) {
797+
this.log("Config file name: " + configFileName, "Info");
798+
} else {
799+
this.log("no config file");
800+
}
775801
if (configFileName) {
776802
configFileName = getAbsolutePath(configFileName, searchPath);
777803
}

0 commit comments

Comments
 (0)