@@ -3775,24 +3775,26 @@ namespace ts.server {
37753775 getPackageJsonsVisibleToFile ( fileName : string , rootDir ?: string ) : readonly PackageJsonInfo [ ] {
37763776 const packageJsonCache = this . packageJsonCache ;
37773777 const watchPackageJsonFile = this . watchPackageJsonFile . bind ( this ) ;
3778- const toPath = this . toPath . bind ( this ) ;
3779- const rootPath = rootDir && toPath ( rootDir ) ;
3780- const filePath = toPath ( fileName ) ;
3778+ const rootPath = rootDir && this . toPath ( rootDir ) ;
3779+ const filePath = this . toPath ( fileName ) ;
37813780 const result : PackageJsonInfo [ ] = [ ] ;
3782- forEachAncestorDirectory ( getDirectoryPath ( filePath ) , function processDirectory ( directory ) : boolean | undefined {
3781+ forEachAncestorDirectory ( getDirectoryPath ( filePath ) , directory => {
37833782 switch ( packageJsonCache . directoryHasPackageJson ( directory ) ) {
37843783 // Sync and check same directory again
37853784 case Ternary . Maybe :
37863785 packageJsonCache . searchDirectoryAndAncestors ( directory ) ;
3787- return processDirectory ( directory ) ;
3788- // Check package.json
3786+ if ( packageJsonCache . directoryHasPackageJson ( directory ) !== Ternary . True ) {
3787+ return false ;
3788+ }
3789+ // fall through
3790+ // Check the package.json
37893791 case Ternary . True :
37903792 const packageJsonFileName = combinePaths ( directory , "package.json" ) ;
37913793 watchPackageJsonFile ( packageJsonFileName ) ;
37923794 const info = packageJsonCache . getInDirectory ( directory ) ;
37933795 if ( info ) result . push ( info ) ;
37943796 }
3795- if ( rootPath && rootPath === toPath ( directory ) ) {
3797+ if ( rootPath && rootPath === this . toPath ( directory ) ) {
37963798 return true ;
37973799 }
37983800 } ) ;
0 commit comments