-
Notifications
You must be signed in to change notification settings - Fork 8.3k
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
Initialize Terminal Preview settings from Terminal settings #12907
Changes from all commits
0694a4e
022cd58
cd7cf1e
e75bc55
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -14,6 +14,7 @@ | |
|
||
static constexpr std::string_view Utf8Bom{ "\xEF\xBB\xBF", 3 }; | ||
static constexpr std::wstring_view UnpackagedSettingsFolderName{ L"Microsoft\\Windows Terminal\\" }; | ||
static constexpr std::wstring_view ReleaseSettingsFolder{ L"Packages\\Microsoft.WindowsTerminal_8wekyb3d8bbwe\\LocalState\\" }; | ||
|
||
namespace winrt::Microsoft::Terminal::Settings::Model | ||
{ | ||
|
@@ -43,6 +44,32 @@ namespace winrt::Microsoft::Terminal::Settings::Model | |
return baseSettingsPath; | ||
} | ||
|
||
// Returns a path like C:\Users\<username>\AppData\Local\Packages\Microsoft.WindowsTerminal_8wekyb3d8bbwe\LocalState | ||
// to the path of the stable release settings | ||
std::filesystem::path GetReleaseSettingsPath() | ||
{ | ||
static std::filesystem::path baseSettingsPath = []() { | ||
wil::unique_cotaskmem_string localAppDataFolder; | ||
// We're using KF_FLAG_NO_PACKAGE_REDIRECTION to ensure that we always get the | ||
// user's actual local AppData directory. | ||
THROW_IF_FAILED(SHGetKnownFolderPath(FOLDERID_LocalAppData, KF_FLAG_NO_PACKAGE_REDIRECTION, nullptr, &localAppDataFolder)); | ||
|
||
// Returns a path like C:\Users\<username>\AppData\Local | ||
std::filesystem::path parentDirectoryForSettingsFile{ localAppDataFolder.get() }; | ||
|
||
//Appending \Packages\Microsoft.WindowsTerminal_8wekyb3d8bbwe\LocalState to the settings path | ||
parentDirectoryForSettingsFile /= ReleaseSettingsFolder; | ||
|
||
if (!IsPackaged()) | ||
{ | ||
parentDirectoryForSettingsFile /= UnpackagedSettingsFolderName; | ||
} | ||
Comment on lines
+61
to
+66
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I'm not sure this is right for unpackaged versions of the Terminal. I might want to tap in @DHowett for this bit, hes a bit more familiar with running the Terminal unpackaged. Just looking at my own files, I've only got a Heck, I'm not sure this is ever relevant for Preview builds running unpackaged - I think they always just use There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yeah -- preview builds just use the same storage as stable when they run unpackaged, so there's no worry here :) |
||
|
||
return parentDirectoryForSettingsFile; | ||
}(); | ||
return baseSettingsPath; | ||
} | ||
|
||
// Function Description: | ||
// - Checks the permissions on this file, to make sure it can only be opened | ||
// for writing by admins. We will be checking to see if the file is owned | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Clever, simple, easy to parse what's happening. 👍