Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add a WT_SETTINGS_DIR env variable that portable profiles can use #16949

Merged
merged 3 commits into from
Mar 28, 2024
Merged
Changes from 1 commit
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
16 changes: 16 additions & 0 deletions src/cascadia/WindowsTerminal/WindowEmperor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -307,6 +307,17 @@ void WindowEmperor::_decrementWindowCount()
}
}

// Function Description
// * Adds a `WT_FOLDER_PATH` env var to our own environment block, that points
// at our parent directory. This allows portable installs to refer to files in
// the portable install using %WT_FOLDER_PATH%
static void _setupFolderPathEnvVar()
{
std::wstring path = wil::GetModuleFileNameW<std::wstring>();
auto folderPath = path.substr(0, path.find_last_of(L"\\"));
SetEnvironmentVariableW(L"WT_FOLDER_PATH", folderPath.c_str());
}

// Method Description:
// - Set up all sorts of handlers now that we've determined that we're a process
// that will end up hosting the windows. These include:
Expand All @@ -320,6 +331,11 @@ void WindowEmperor::_decrementWindowCount()
// - <none>
void WindowEmperor::_becomeMonarch()
{
// Do this here, rather than at the top of main. This will prevent us from
// including this variable in the vars we serialize in the
// Remoting::CommandlineArgs up in HandleCommandlineArgs.
_setupFolderPathEnvVar();

// Add a callback to the window manager so that when the Monarch wants a new
// window made, they come to us
_manager.RequestNewWindow([this](auto&&, const Remoting::WindowRequestedArgs& args) {
Expand Down
Loading