@@ -3775,24 +3775,28 @@ namespace ts.server {
3775
3775
getPackageJsonsVisibleToFile ( fileName : string , rootDir ?: string ) : readonly PackageJsonInfo [ ] {
3776
3776
const packageJsonCache = this . packageJsonCache ;
3777
3777
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 ) ;
3781
3780
const result : PackageJsonInfo [ ] = [ ] ;
3782
- forEachAncestorDirectory ( getDirectoryPath ( filePath ) , function processDirectory ( directory ) : boolean | undefined {
3781
+ forEachAncestorDirectory ( getDirectoryPath ( filePath ) , directory => {
3783
3782
switch ( packageJsonCache . directoryHasPackageJson ( directory ) ) {
3784
3783
// Sync and check same directory again
3785
3784
case Ternary . Maybe :
3786
3785
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
3789
3793
case Ternary . True :
3790
3794
const packageJsonFileName = combinePaths ( directory , "package.json" ) ;
3791
3795
watchPackageJsonFile ( packageJsonFileName ) ;
3792
3796
const info = packageJsonCache . getInDirectory ( directory ) ;
3793
3797
if ( info ) result . push ( info ) ;
3794
3798
}
3795
- if ( rootPath && rootPath === toPath ( directory ) ) {
3799
+ if ( rootPath && rootPath === this . toPath ( directory ) ) {
3796
3800
return true ;
3797
3801
}
3798
3802
} ) ;
0 commit comments