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).
This commit is contained in:
Bill committed 2026-09-14 19:52:32 +08:00
1 parent 9a330499de
commit 01827bf70b
1 file changed
+7
+7
View File
@@ -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 `<base>\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