@@ -3775,24 +3775,28 @@ 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+ const newResult = packageJsonCache . directoryHasPackageJson ( directory ) ;
3787+ if ( newResult !== Ternary . True ) {
3788+ Debug . assertEqual ( newResult , Ternary . False ) ;
3789+ break ;
3790+ }
3791+ // fall through
3792+ // Check the package.json
37893793 case Ternary . True :
37903794 const packageJsonFileName = combinePaths ( directory , "package.json" ) ;
37913795 watchPackageJsonFile ( packageJsonFileName ) ;
37923796 const info = packageJsonCache . getInDirectory ( directory ) ;
37933797 if ( info ) result . push ( info ) ;
37943798 }
3795- if ( rootPath && rootPath === toPath ( directory ) ) {
3799+ if ( rootPath && rootPath === this . toPath ( directory ) ) {
37963800 return true ;
37973801 }
37983802 } ) ;
0 commit comments