-
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
Patch the default profile and version into the settings template #5232
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
an auto function
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.
holy shit this works?
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.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I wonder how many projects have had to write this exact thing.
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.
:laughing_but_crying_inside:
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.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Wait why are we making another winrt::com_ptr<winrt::TerminalApp::implementation::AppLogic>
here?
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.
so actually get_self returns a raw implementation::X*
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.
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() |
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.
holy shit this works?
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
:laughing_but_crying_inside:
} | ||
|
||
return profiles; | ||
} | ||
|
||
// Function Description: | ||
// - Returns the thing it's named for. |
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.
too cheeky?
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.
Eh. Always nice to have a few of these sprinkled throughout haha
} | ||
|
||
return profiles; | ||
} | ||
|
||
// Function Description: | ||
// - Returns the thing it's named for. |
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.
Eh. Always nice to have a few of these sprinkled throughout haha
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.
Okay sure. It's a little gross but there's not a totally better way (re: the AppLogic::Current
stuff)
🎉 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
VERSION
andPRODUCT
).PR Checklist
Validation Steps Performed
Deleted my settings and watched them regenerate.