From 01827bf70baf8b4b3e654d542503477fe1740614 Mon Sep 17 00:00:00 2001 From: Bill Date: Mon, 14 Sep 2026 19:52:32 +0800 Subject: [PATCH] fix: resolve drive-relative cd (cd d:) in cwd memory path.isAbsolute('d:') is false on Windows, so a drive-relative cd resolved against the current base, produced a nonexistent path, and the pane kept its creation directory in the snapshot. Map a bare drive-letter argument to the drive root (the fresh-shell answer; we cannot know the drive's remembered directory). --- src/main/cwd.ts | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/main/cwd.ts b/src/main/cwd.ts index 8e845ec..1e3575b 100644 --- a/src/main/cwd.ts +++ b/src/main/cwd.ts @@ -37,6 +37,13 @@ export function resolveCwd(current: string | undefined, rawArg: string): string } // `cd -` means the shell's previous directory, which we cannot know here. if (arg === '-') return null + // Drive-relative `cd d:` (cmd/PowerShell): the target is the drive's + // current directory, which the shell never tells us — path.isAbsolute('d:') + // is false, so without this branch it resolves against the base and dies on + // a nonexistent `\d:`. The drive root is the fresh-shell answer. + if (process.platform === 'win32' && /^[a-zA-Z]:$/.test(arg)) { + return existingDir(`${arg.toUpperCase()}\\`) + } const base = current && current.trim() ? current : homedir() // An absolute argument wins; otherwise resolve against the base. Both forms