File tree Expand file tree Collapse file tree 1 file changed +27
-1
lines changed
Expand file tree Collapse file tree 1 file changed +27
-1
lines changed Original file line number Diff line number Diff 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 }
You can’t perform that action at this time.
0 commit comments