-
Notifications
You must be signed in to change notification settings - Fork 8.4k
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
Make Global and Profile settings inheritable #7923
Conversation
TODO for this PR
(new items!)
(new items 2!)
(new items 3!)
|
src/inc/til/coalesce.h
Outdated
// Method Description: | ||
// - Base case provided to throw an assertion if you call coalesce_value(opt, opt, opt) | ||
template<typename T> | ||
T coalesce_value(const winrt::Windows::Foundation::IReference<T>& base) |
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.
til cannot have an unguarded reference to IReference
. til
is conceptually below things that use winrt.
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.
oh i see, you.. did the thing i did in JsonUtils. Clever.
src/cascadia/TerminalSettingsModel/CascadiaSettingsSerialization.cpp
Outdated
Show resolved
Hide resolved
src/cascadia/TerminalSettingsModel/CascadiaSettingsSerialization.cpp
Outdated
Show resolved
Hide resolved
This comment has been minimized.
This comment has been minimized.
src/cascadia/TerminalSettingsModel/CascadiaSettingsSerialization.cpp
Outdated
Show resolved
Hide resolved
src/cascadia/TerminalSettingsModel/CascadiaSettingsSerialization.cpp
Outdated
Show resolved
Hide resolved
must-fix:
pleasant to have:
|
|
||
com_ptr<KeyMapping> _keymap; | ||
std::vector<SettingsLoadWarnings> _keybindingsWarnings; | ||
|
||
Windows::Foundation::Collections::IMap<hstring, Model::ColorScheme> _colorSchemes; | ||
Windows::Foundation::Collections::IMap<hstring, Model::Command> _commands; | ||
|
||
std::optional<hstring> _getUnparsedDefaultProfileImpl() const; |
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.
how is this different from GETSET_SETTING
?
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.
The setter for UnparsedDefaultProfile needs to set _validDefaultProfile
to false. We need this to validate that the provided "defaultProfile" value actually maps to something.
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.
Let's do this.
// Special case the legacy dynamic profiles here. In this case, | ||
// `this` is a dynamic profile with a source, and our _source is one | ||
// of the legacy DPG namespaces. We're looking to see if the other | ||
// json object has the same guid, but _no_ "source" | ||
if (_Source == WslGeneratorNamespace || | ||
_Source == AzureGeneratorNamespace || | ||
_Source == PowershellCoreGeneratorNamespace) | ||
if (mySource == WslGeneratorNamespace || | ||
mySource == AzureGeneratorNamespace || | ||
mySource == PowershellCoreGeneratorNamespace) | ||
{ |
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.
FYI @carlos-zamora this is the code that makes "source" optional for the pre-0.5 dynamic generators
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.
Good work landing all this, it's a complicated change in a complicated codebase, but looks like it should work. I'm sure we'll find out very fast if it doesn't 😄
@@ -73,10 +69,11 @@ namespace winrt::Microsoft::Terminal::Settings::Model::implementation | |||
const Windows::UI::Xaml::VerticalAlignment BackgroundImageVerticalAlignment() const noexcept; | |||
void BackgroundImageVerticalAlignment(const Windows::UI::Xaml::VerticalAlignment& value) noexcept; | |||
|
|||
GETSET_SETTING(guid, Guid); | |||
GETSET_SETTING(guid, Guid, _GenerateGuidForProfile(Name(), Source())); |
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 shocked that this works, but I get why it does
Hello @carlos-zamora! Because this pull request has the p.s. you can customize the way I help with merging this pull request, such as holding this pull request until a specific person approves. Simply @mention me (
|
🎉 Handy links: |
## Summary of the Pull Request This adds `ToJson` functions to `Profile`, `GlobalAppSettings`, and `ColorScheme`. They are used in `CascadiaSettings` to completely serialize an instance of the settings model. Thanks to #7923, all of the settings are `std::optional`, and `JsonUtils` only writes out values that are actually populated. `CascadiaSettings::WriteSettingsToDisk` serializes the current settings and writes them to the settings.json. A backup file is created with your old contents. #### Limitations: - all of the color schemes are serialized regardless of them coming from defaults.json or settings.json - keybindings/actions are copied/pasted ## References #1564 - Settings UI TSM Specs (#6904 and #7876) ## PR Checklist * [x] Tests added/passed
The Settings UI exposes the `profiles.defaults` (PD) object. Today, we remove PD if there's nothing in it. However, that causes problems with the Settings UI, because we have no `Profile` object to bind to (resulting in a crash). Rather than making the Settings UI create a PD, and link it in the inheritance tree, it's much easier to just _always_ create and link the PD object. ## References #1564 - Settings UI (fixes a crash for this) #7923 - Introduces inheritance ## PR Checklist * [X] Tests added/passed ## Validation Steps Performed * [x] repro steps for crash in Settings UI (copied changes over to that branch for testing) * [x] tests passed
Summary of the Pull Request
Introduces
IInheritable
as an interface that helps move cascading settings into the Terminal Settings Model.GlobalAppSettings
andProfile
both are nowIInheritable
.CascadiaSettings
was updated toCreateChild()
for globals and each profile when we are loading the JSON data.IInheritable does most of the heavy lifting. It introduces a two new macros and the interface. The macros help implement the fallback functionality for nullable and non-nullable settings.
References
#7876 - Spec Addendum
#6904 - TSM Spec
#1564 - Settings UI
#7876 -
Copy()
needs to be updated to include _parent