Fix cwd not applying on launch (#18801)

(cherry picked from commit 3accdcfc6bf17a6b3fc4dfc26b816ba16ec410de)
Service-Card-Id: PVTI_lADOAF3p4s4AxadtzgZa8w8
Service-Version: 1.23
This commit is contained in:
Leonard Hecker 2025-04-15 22:22:09 +02:00 committed by Dustin L. Howett
parent 840f9623e5
commit b2cf9d1bac
3 changed files with 6 additions and 4 deletions

View File

@ -17,7 +17,7 @@ namespace winrt::TerminalApp::implementation
{ {
CommandlineArgs::CommandlineArgs(winrt::array_view<const winrt::hstring> args, winrt::hstring currentDirectory, uint32_t showWindowCommand, winrt::hstring envString) : CommandlineArgs::CommandlineArgs(winrt::array_view<const winrt::hstring> args, winrt::hstring currentDirectory, uint32_t showWindowCommand, winrt::hstring envString) :
_args{ args.begin(), args.end() }, _args{ args.begin(), args.end() },
_cwd{ std::move(currentDirectory) }, CurrentDirectory{ std::move(currentDirectory) },
ShowWindowCommand{ showWindowCommand }, ShowWindowCommand{ showWindowCommand },
CurrentEnvironment{ std::move(envString) } CurrentEnvironment{ std::move(envString) }
{ {

View File

@ -36,7 +36,6 @@ namespace winrt::TerminalApp::implementation
::TerminalApp::AppCommandlineArgs _parsed; ::TerminalApp::AppCommandlineArgs _parsed;
int32_t _parseResult = 0; int32_t _parseResult = 0;
winrt::com_array<winrt::hstring> _args; winrt::com_array<winrt::hstring> _args;
winrt::hstring _cwd;
}; };
struct RequestReceiveContentArgs : RequestReceiveContentArgsT<RequestReceiveContentArgs> struct RequestReceiveContentArgs : RequestReceiveContentArgsT<RequestReceiveContentArgs>

View File

@ -563,8 +563,11 @@ namespace winrt::TerminalApp::implementation
_WindowProperties.VirtualEnvVars(originalVirtualEnv); _WindowProperties.VirtualEnvVars(originalVirtualEnv);
} }
}); });
_WindowProperties.VirtualWorkingDirectory(cwd); if (!cwd.empty())
_WindowProperties.VirtualEnvVars(env); {
_WindowProperties.VirtualWorkingDirectory(cwd);
_WindowProperties.VirtualEnvVars(env);
}
for (size_t i = 0; i < actions.size(); ++i) for (size_t i = 0; i < actions.size(); ++i)
{ {