Skip to content

Commit 2ba4a12

Browse files
committed
When determining ancestor directory to watch use that directory itself to determine if ok to watch
1 parent 7a07449 commit 2ba4a12

7 files changed

+239
-238
lines changed

src/compiler/resolutionCache.ts

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -319,19 +319,16 @@ function getDirectoryToWatchFromFailedLookupLocationDirectory(
319319
}
320320
// Use some ancestor of the root directory
321321
let nonRecursive = true;
322-
let subDirectoryPath: PathPathComponents | undefined, subDirectory: string[] | undefined;
323322
for (let i = 0; i < dirPathComponents.length; i++) {
324323
if (dirPathComponents[i] !== rootPathComponents[i]) {
325324
nonRecursive = false;
326-
subDirectory = dirComponents.slice(0, i + 1);
327-
subDirectoryPath = dirPathComponents.slice(0, i + 1) as PathPathComponents;
328-
dirPathComponents.length = i;
329-
dirComponents.length = i;
325+
dirComponents.length = i + 1;
326+
dirPathComponents.length = i + 1;
330327
break;
331328
}
332329
}
333330
return canWatchDirectoryOrFile(dirPathComponents) ?
334-
getDirectoryOfFailedLookupWatch(subDirectory || dirComponents, subDirectoryPath || dirPathComponents, nonRecursive) :
331+
getDirectoryOfFailedLookupWatch(dirComponents, dirPathComponents, nonRecursive) :
335332
undefined;
336333
}
337334

tests/baselines/reference/canWatch/getDirectoryToWatchFailedLookupLocationDos.baseline.md

Lines changed: 62 additions & 62 deletions
Large diffs are not rendered by default.

tests/baselines/reference/canWatch/getDirectoryToWatchFailedLookupLocationPosix.baseline.md

Lines changed: 46 additions & 46 deletions
Large diffs are not rendered by default.

tests/baselines/reference/canWatch/getDirectoryToWatchFailedLookupLocationUnc.baseline.md

Lines changed: 62 additions & 62 deletions
Large diffs are not rendered by default.

tests/baselines/reference/canWatch/getDirectoryToWatchFailedLookupLocationUncDos.baseline.md

Lines changed: 62 additions & 62 deletions
Large diffs are not rendered by default.

tests/baselines/reference/tsserver/resolutionCache/when-resolution-fails.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,8 @@ Info seq [hh:mm:ss:mss] DirectoryWatcher:: Added:: WatchInfo: /user/username/pr
6767
Info seq [hh:mm:ss:mss] Elapsed:: *ms DirectoryWatcher:: Added:: WatchInfo: /user/username/projects/myproject/src/somefolder 1 undefined Project: /user/username/projects/myproject/src/tsconfig.json WatchType: Failed Lookup Locations
6868
Info seq [hh:mm:ss:mss] DirectoryWatcher:: Added:: WatchInfo: /user/username/projects/myproject/somefolder 1 undefined Project: /user/username/projects/myproject/src/tsconfig.json WatchType: Failed Lookup Locations
6969
Info seq [hh:mm:ss:mss] Elapsed:: *ms DirectoryWatcher:: Added:: WatchInfo: /user/username/projects/myproject/somefolder 1 undefined Project: /user/username/projects/myproject/src/tsconfig.json WatchType: Failed Lookup Locations
70+
Info seq [hh:mm:ss:mss] DirectoryWatcher:: Added:: WatchInfo: /user/username/projects/somefolder 1 undefined Project: /user/username/projects/myproject/src/tsconfig.json WatchType: Failed Lookup Locations
71+
Info seq [hh:mm:ss:mss] Elapsed:: *ms DirectoryWatcher:: Added:: WatchInfo: /user/username/projects/somefolder 1 undefined Project: /user/username/projects/myproject/src/tsconfig.json WatchType: Failed Lookup Locations
7072
Info seq [hh:mm:ss:mss] DirectoryWatcher:: Added:: WatchInfo: /user/username/projects/myproject/src/node_modules 1 undefined Project: /user/username/projects/myproject/src/tsconfig.json WatchType: Failed Lookup Locations
7173
Info seq [hh:mm:ss:mss] Elapsed:: *ms DirectoryWatcher:: Added:: WatchInfo: /user/username/projects/myproject/src/node_modules 1 undefined Project: /user/username/projects/myproject/src/tsconfig.json WatchType: Failed Lookup Locations
7274
Info seq [hh:mm:ss:mss] DirectoryWatcher:: Added:: WatchInfo: /user/username/projects/myproject/node_modules 1 undefined Project: /user/username/projects/myproject/src/tsconfig.json WatchType: Failed Lookup Locations

tests/baselines/reference/tsserver/resolutionCache/when-resolves-to-ambient-module.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,8 @@ Info seq [hh:mm:ss:mss] DirectoryWatcher:: Added:: WatchInfo: /user/username/pr
7676
Info seq [hh:mm:ss:mss] Elapsed:: *ms DirectoryWatcher:: Added:: WatchInfo: /user/username/projects/myproject/src/somefolder 1 undefined Project: /user/username/projects/myproject/src/tsconfig.json WatchType: Failed Lookup Locations
7777
Info seq [hh:mm:ss:mss] DirectoryWatcher:: Added:: WatchInfo: /user/username/projects/myproject/somefolder 1 undefined Project: /user/username/projects/myproject/src/tsconfig.json WatchType: Failed Lookup Locations
7878
Info seq [hh:mm:ss:mss] Elapsed:: *ms DirectoryWatcher:: Added:: WatchInfo: /user/username/projects/myproject/somefolder 1 undefined Project: /user/username/projects/myproject/src/tsconfig.json WatchType: Failed Lookup Locations
79+
Info seq [hh:mm:ss:mss] DirectoryWatcher:: Added:: WatchInfo: /user/username/projects/somefolder 1 undefined Project: /user/username/projects/myproject/src/tsconfig.json WatchType: Failed Lookup Locations
80+
Info seq [hh:mm:ss:mss] Elapsed:: *ms DirectoryWatcher:: Added:: WatchInfo: /user/username/projects/somefolder 1 undefined Project: /user/username/projects/myproject/src/tsconfig.json WatchType: Failed Lookup Locations
7981
Info seq [hh:mm:ss:mss] DirectoryWatcher:: Added:: WatchInfo: /user/username/projects/myproject/src/node_modules 1 undefined Project: /user/username/projects/myproject/src/tsconfig.json WatchType: Failed Lookup Locations
8082
Info seq [hh:mm:ss:mss] Elapsed:: *ms DirectoryWatcher:: Added:: WatchInfo: /user/username/projects/myproject/src/node_modules 1 undefined Project: /user/username/projects/myproject/src/tsconfig.json WatchType: Failed Lookup Locations
8183
Info seq [hh:mm:ss:mss] DirectoryWatcher:: Added:: WatchInfo: /user/username/projects/myproject/node_modules 1 undefined Project: /user/username/projects/myproject/src/tsconfig.json WatchType: Failed Lookup Locations

0 commit comments

Comments
 (0)