Patch the default profile and version into the settings template#5232
Patch the default profile and version into the settings template#5232DHowett-MSFT merged 4 commits intomasterfrom
Conversation
|
Had to move version stuff up to Logic (app level). I prefer it there, but there is some duplication in the exception handler (because we might not have an AppLogic, AND package APIs may fail). |
| // Throws: | ||
| // - HR E_INVALIDARG if the app isn't up and running. | ||
| const CascadiaSettings& CascadiaSettings::GetCurrentAppSettings() | ||
| static auto GetAppLogic() |
There was a problem hiding this comment.
an auto function
There was a problem hiding this comment.
IT IS A REVOLUTION
| auto replace{ [](std::string& haystack, std::string_view needle, std::string_view replacement) { | ||
| auto pos{ std::string::npos }; | ||
| while ((pos = haystack.rfind(needle, pos)) != std::string::npos) | ||
| { | ||
| haystack.replace(pos, needle.size(), replacement); | ||
| } | ||
| } }; |
There was a problem hiding this comment.
I wonder how many projects have had to write this exact thing.
There was a problem hiding this comment.
:laughing_but_crying_inside:
zadjii-msft
left a comment
There was a problem hiding this comment.
I'm really okay with this, but IIRC this has a issue that needs to be linked to it
| winrt::com_ptr<winrt::TerminalApp::implementation::AppLogic> appLogic; | ||
| appLogic.copy_from(appLogicPointer); | ||
| return appLogic; |
There was a problem hiding this comment.
Wait why are we making another winrt::com_ptr<winrt::TerminalApp::implementation::AppLogic> here?
There was a problem hiding this comment.
so actually get_self returns a raw implementation::X*
There was a problem hiding this comment.
Honestly i don't know if I care to have this return a com_ptr. a bare pointer means it can't be owned, but the AppLogic should outlive ALL other lifetimes...
| // Throws: | ||
| // - HR E_INVALIDARG if the app isn't up and running. | ||
| const CascadiaSettings& CascadiaSettings::GetCurrentAppSettings() | ||
| static auto GetAppLogic() |
| auto replace{ [](std::string& haystack, std::string_view needle, std::string_view replacement) { | ||
| auto pos{ std::string::npos }; | ||
| while ((pos = haystack.rfind(needle, pos)) != std::string::npos) | ||
| { | ||
| haystack.replace(pos, needle.size(), replacement); | ||
| } | ||
| } }; |
There was a problem hiding this comment.
:laughing_but_crying_inside:
| } | ||
|
|
||
| // Function Description: | ||
| // - Returns the thing it's named for. |
There was a problem hiding this comment.
Eh. Always nice to have a few of these sprinkled throughout haha
| } | ||
|
|
||
| // Function Description: | ||
| // - Returns the thing it's named for. |
There was a problem hiding this comment.
Eh. Always nice to have a few of these sprinkled throughout haha
|
🎉 Handy links: |
This pull request introduces unexpanded variables (
%DEFAULT_PROFILE%,%VERSION%and%PRODUCT%) to the user settings template and code toexpand them.
While doing this, I ran into a couple things that needed to widen from
accepting strings to accepting string views. I also had to move
application name and version detection up to AppLogic and expose the
AppLogic singleton.
The dynamic profile generation logic had to be moved to before we inject
the templated variables, as the new default profile depends on the
generated dynamic profiles.
References #5189, #5217 (because it has a dependency on
VERSIONandPRODUCT).PR Checklist
Validation Steps Performed
Deleted my settings and watched them regenerate.