Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 11 additions & 4 deletions packages/code/src/workspace.ts
Original file line number Diff line number Diff line change
Expand Up @@ -809,8 +809,10 @@ async function hasMissingParent(root: string, path: string): Promise<boolean> {
* or `--environment`) under a descriptor held for just this request when its
* parent is missing, so the mutation, parent creation included, takes the same
* anchored path a selected project root does and a swapped symlink cannot
* redirect it outside the root. A held root, an existing parent, or a host that
* cannot anchor the root runs the mutation as before.
* redirect it outside the root. A held root or an existing parent runs the
* mutation as before; a root that is no longer a real directory at its path
* runs it unanchored and is refused there, creating nothing. A root that
* changes between its capture and its open is refused as `INVALID_PATH`.
*/
async function withAnchoredParentCreation<T>(
root: string,
Expand All @@ -823,8 +825,13 @@ async function withAnchoredParentCreation<T>(
try {
return await withWorkspaceRoot(root, identity, action);
} catch (error) {
/** Raised only while opening the root, before `action` ran. */
if (error instanceof WorkspaceRootAccessError) return action();
/**
* Raised only while opening the root, before `action` ran: the root changed after its
* identity was captured. Never retry unanchored against whatever replaced it.
*/
if (error instanceof WorkspaceRootAccessError) {
throw new WorkspaceToolError('Invalid workspace path', 'INVALID_PATH');
}
throw error;
}
}
Expand Down
Loading