-
Notifications
You must be signed in to change notification settings - Fork 3.4k
fix: include Windows directory junctions in project browser #2798
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,4 +1,5 @@ | ||
| // @effect-diagnostics nodeBuiltinImport:off | ||
| import type { Dirent } from "node:fs"; | ||
| import * as NodeFSP from "node:fs/promises"; | ||
| import * as NodeOS from "node:os"; | ||
|
|
||
|
|
@@ -97,6 +98,41 @@ export class WorkspaceEntries extends Context.Service< | |
| } | ||
| >()("t3/workspace/WorkspaceEntries") {} | ||
|
|
||
| const WINDOWS_LEGACY_PROFILE_JUNCTION_NAMES = new Set([ | ||
| "Application Data", | ||
| "Cookies", | ||
| "Local Settings", | ||
| "My Documents", | ||
| "NetHood", | ||
| "PrintHood", | ||
| "Recent", | ||
| "SendTo", | ||
| "Start Menu", | ||
| "Templates", | ||
| ]); | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Incomplete Windows junction denylistMedium Severity
Reviewed by Cursor Bugbot for commit ae46c95. Configure here. |
||
|
|
||
| async function isDirectoryEntry( | ||
| dirent: Dirent, | ||
| fullPath: string, | ||
| platform: NodeJS.Platform, | ||
| ): Promise<boolean> { | ||
| if (dirent.isDirectory()) { | ||
| return true; | ||
| } | ||
| if (!dirent.isSymbolicLink()) { | ||
| return false; | ||
| } | ||
| if (platform === "win32" && WINDOWS_LEGACY_PROFILE_JUNCTION_NAMES.has(dirent.name)) { | ||
| return false; | ||
| } | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Legacy junction filter too broadLow Severity On Windows, the Reviewed by Cursor Bugbot for commit ae46c95. Configure here. |
||
|
|
||
| try { | ||
| return (await NodeFSP.stat(fullPath)).isDirectory(); | ||
| } catch { | ||
| return false; | ||
| } | ||
| } | ||
|
|
||
| function expandHomePath(input: string, path: Path.Path): string { | ||
| if (input === "~") { | ||
| return NodeOS.homedir(); | ||
|
|
@@ -134,6 +170,7 @@ const resolveBrowseTarget = Effect.fn("WorkspaceEntries.resolveBrowseTarget")(fu | |
|
|
||
| export const make = Effect.gen(function* () { | ||
| const path = yield* Path.Path; | ||
| const platform = yield* HostProcessPlatform; | ||
| const workspacePaths = yield* WorkspacePaths.WorkspacePaths; | ||
| const workspaceSearchIndexes = yield* WorkspaceSearchIndex.WorkspaceSearchIndexMap; | ||
|
|
||
|
|
@@ -206,23 +243,28 @@ export const make = Effect.gen(function* () { | |
|
|
||
| const showHidden = endsWithSeparator || prefix.startsWith("."); | ||
| const lowerPrefix = prefix.toLowerCase(); | ||
| const entries: Array<{ readonly name: string; readonly fullPath: string }> = []; | ||
| for (const dirent of dirents) { | ||
| if ( | ||
| dirent.isDirectory() && | ||
| dirent.name.toLowerCase().startsWith(lowerPrefix) && | ||
| (showHidden || !dirent.name.startsWith(".")) | ||
| ) { | ||
| entries.push({ | ||
| name: dirent.name, | ||
| fullPath: path.join(parentPath, dirent.name), | ||
| }); | ||
| } | ||
| } | ||
| const entries = yield* Effect.forEach( | ||
| dirents, | ||
| (dirent) => | ||
| Effect.promise(async () => { | ||
| const fullPath = path.join(parentPath, dirent.name); | ||
| if ( | ||
| !dirent.name.toLowerCase().startsWith(lowerPrefix) || | ||
| (!showHidden && dirent.name.startsWith(".")) || | ||
| !(await isDirectoryEntry(dirent, fullPath, platform)) | ||
| ) { | ||
| return null; | ||
| } | ||
| return { name: dirent.name, fullPath }; | ||
| }), | ||
| { concurrency: 16 }, | ||
| ); | ||
|
|
||
| return { | ||
| parentPath, | ||
| entries: entries.toSorted((left, right) => left.name.localeCompare(right.name)), | ||
| entries: entries | ||
| .filter((entry): entry is NonNullable<typeof entry> => entry !== null) | ||
| .toSorted((left, right) => left.name.localeCompare(right.name)), | ||
| }; | ||
| }, | ||
| ); | ||
|
|
||


There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Symlink regression test cannot run
Medium Severity
The new browse symlink regression test calls
fsPromises.symlink, but this file only imports the fs promises module asNodeFSP. Setup throws beforebrowseruns, so the only coverage for directory symlink/junction inclusion never executes.Reviewed by Cursor Bugbot for commit ae46c95. Configure here.