Fix splitting pane fails when CWD is a PSDrive (#20373)#20379
Conversation
|
@microsoft-github-policy-service agree |
DHowett
left a comment
There was a problem hiding this comment.
Well, so, PowerShell doesn't come with shell integration.
Wouldn't it be easier for the user who filed the bug to fix their profile to emit $PWD.ProviderPath instead of $PWD?
|
That's a fair point, and yeah, the doc snippet at learn.microsoft.com/en-us/windows/terminal/tutorials/shell-integration uses That said, I'd like to keep this validation in Happy to narrow the PR if you'd rather this be handled purely as a docs fix, just let me know. |
|
(We'll need to comport it with #20094 as well) |
|
Yeah, looked closer and you're right, #20094 drops the The only place both old and new code actually share is the OSC 9;9 parsing in Can't just slap a strict Win32-path check there either, Want me to take a pass at that, or hold off until #20094 settles so I'm not stepping on it? |
Summary of the Pull Request
Fixes pane splitting failing when the active shell's working directory is a PowerShell PSDrive path instead of a real filesystem path.
References and Relevant Issues
Fixes #20373
Detailed Description of the Pull Request / Additional comments
When splitting a pane, TerminalPage reads the current pane's working directory from control.WorkingDirectory() and uses it as the new pane's starting directory if Utils::IsValidDirectory() returns true.
PowerShell reports its CWD through shell integration using $PWD.Path. For a PSDrive (created with New-PSDrive -Name src -Root C:\src), this returns the provider path src:\ instead of the real filesystem path. IsValidDirectory() only ran GetFileAttributesExW on the string without checking that it is a well formed Win32 path, so src:\ passed validation and was handed to ConptyConnection, then to CreateProcess's lpCurrentDirectory, where it resolved relative to the host process's own CWD instead of failing cleanly. That produced the launch error in the original report.
This PR adds a check in IsValidDirectory that requires the path to be a single drive letter path (C:...) or a UNC path (\server\share...) before checking the filesystem. Provider paths like src:\ now fail validation immediately, so the split falls back to the profile's default starting directory instead of launching with a broken one.
PR Checklist