Skip to content

Commit 7046d66

Browse files
authored
Fix infinite recursion in getDirectoryHandle (microsoft#145972)
While opening the root dir (or disk root on windows), launch debug, `getDirectoryHandle` will try to find its parent dir. However `dirname(root)` returns root itself. This caused UI freezed on web target. Add equal detection to fix this bug.
1 parent 4db0b18 commit 7046d66

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

src/vs/platform/files/browser/htmlFileSystemProvider.ts

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -382,7 +382,12 @@ export class HTMLFileSystemProvider implements IFileSystemProviderWithFileReadWr
382382
return handle;
383383
}
384384

385-
const parent = await this.getDirectoryHandle(this.extUri.dirname(resource));
385+
const parentUri = this.extUri.dirname(resource);
386+
if (this.extUri.isEqual(parentUri, resource)) {
387+
return undefined; // return when root is reached to prevent infinite recursion
388+
}
389+
390+
const parent = await this.getDirectoryHandle(parentUri);
386391

387392
try {
388393
return await parent?.getDirectoryHandle(extUri.basename(resource));

0 commit comments

Comments
 (0)