Fix broken reset button on some profile settings#12275
Conversation
| else if (viewModelProperty == L"AntialiasingMode") | ||
| { | ||
| _NotifyChanges(L"CurrentAntiAliasingMode"); | ||
| } | ||
| else if (viewModelProperty == L"CloseOnExit") | ||
| { | ||
| _NotifyChanges(L"CurrentCloseOnExitMode"); | ||
| } | ||
| else if (viewModelProperty == L"BellStyle") | ||
| { | ||
| _NotifyChanges(L"IsBellStyleFlagSet"); | ||
| } | ||
| else if (viewModelProperty == L"ScrollState") | ||
| { | ||
| _NotifyChanges(L"CurrentScrollState"); | ||
| } |
There was a problem hiding this comment.
This got moved over from Profiles.cpp.
This is step 2 of my PR description.
| GETSET_BINDABLE_ENUM_SETTING(AntiAliasingMode, Microsoft::Terminal::Control::TextAntialiasingMode, AntialiasingMode); | ||
| GETSET_BINDABLE_ENUM_SETTING(CloseOnExitMode, Microsoft::Terminal::Settings::Model::CloseOnExitMode, CloseOnExit); | ||
| GETSET_BINDABLE_ENUM_SETTING(ScrollState, Microsoft::Terminal::Control::ScrollbarState, ScrollState); |
There was a problem hiding this comment.
Had to move this down so that it could find the getters/setters defined in the OBSERVABLE_PROJECTED_SETTING macros above.
There was a problem hiding this comment.
Do you want to leave a comment that says "don't shuffle this section up or you're gonna have a bad time?"
There was a problem hiding this comment.
Eh, if somebody moves them, the errors are pretty clear. So I think it's fine.
| #define GETSET_BINDABLE_ENUM_SETTING(name, enumType, viewModelSettingGetSet) \ | ||
| public: \ | ||
| winrt::Windows::Foundation::Collections::IObservableVector<winrt::Microsoft::Terminal::Settings::Editor::EnumEntry> name##List() \ | ||
| { \ | ||
| return _##name##List; \ | ||
| } \ | ||
| \ | ||
| winrt::Windows::Foundation::IInspectable Current##name() \ | ||
| { \ | ||
| return winrt::box_value<winrt::Microsoft::Terminal::Settings::Editor::EnumEntry>(_##name##Map.Lookup(viewModelSettingGetSet())); \ | ||
| } \ | ||
| \ | ||
| void Current##name(const winrt::Windows::Foundation::IInspectable& enumEntry) \ | ||
| { \ | ||
| if (auto ee = enumEntry.try_as<winrt::Microsoft::Terminal::Settings::Editor::EnumEntry>()) \ | ||
| { \ | ||
| auto setting = winrt::unbox_value<enumType>(ee.EnumValue()); \ | ||
| viewModelSettingGetSet(setting); \ | ||
| } \ | ||
| } \ |
There was a problem hiding this comment.
This change is what I was talking about in step 1 of my PR description.
| Opacity(1.0); | ||
| } | ||
| } | ||
| else if (viewModelProperty == L"AntialiasingMode") |
There was a problem hiding this comment.
Just double checking... the property is "Antialiasing" (with the "A" of "aliasing") being lowercase while the Notification string is "AntiAliasing" (with a capital "A")?
It may very well have already been like that and you just copy/pasted... but I'm just checking as it stood out to me.
There was a problem hiding this comment.
Yeah, I was actually really surprised this worked haha.
| GETSET_BINDABLE_ENUM_SETTING(AntiAliasingMode, Microsoft::Terminal::Control::TextAntialiasingMode, AntialiasingMode); | ||
| GETSET_BINDABLE_ENUM_SETTING(CloseOnExitMode, Microsoft::Terminal::Settings::Model::CloseOnExitMode, CloseOnExit); | ||
| GETSET_BINDABLE_ENUM_SETTING(ScrollState, Microsoft::Terminal::Control::ScrollbarState, ScrollState); |
There was a problem hiding this comment.
Do you want to leave a comment that says "don't shuffle this section up or you're gonna have a bad time?"
| // and propagate those changes to the UI | ||
| _ViewModelChangedRevoker = _Profile.PropertyChanged(winrt::auto_revoke, [=](auto&&, const PropertyChangedEventArgs& args) { | ||
| const auto settingName{ args.PropertyName() }; | ||
| if (settingName == L"AntialiasingMode") |
There was a problem hiding this comment.
Oh yeah look the case mismatch was over here too. Ah well.
|
build is failing but i am going to mark automerge anyway -- let's get this in! |
|
Hello @DHowett! Because this pull request has the Do note that I've been instructed to only help merge pull requests of this repository that have been opened for at least 8 hours, a condition that will be fulfilled in about 6 hours 39 minutes. No worries though, I will be back when the time is right! 😉 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 (
|
|
@msftbot merge this in 5 minutes |
|
Hello @DHowett! Because you've given me some instructions on how to help merge this pull request, I'll be modifying my merge approach. Here's how I understand your requirements for merging this pull request:
If this doesn't seem right to you, you can tell me to cancel these instructions and use the auto-merge policy that has been configured for this repository. Try telling me "forget everything I just told you". |
This fixes a bug where several settings would not show the reset button. The root cause of this issue is two fold: 1. Hooking up `CurrentXXX` - `GETSET_BINDABLE_ENUM_SETTING` was hooked up to the **settings** model profile object instead of the **view** model profile object. Since the settings model has no `PropertyChanged` system, any changes were directly being applied to the setting, but not notifying the view model (and thus, the view, by extension) to update themselves. - This fix required me to slightly modify the macro. Rather than using two parameters (object and function name), I used one parameter (path to getter/setter). 2. Responding to the `PropertyChanged` notifications - Now that we're actually dispatching the `PropertyChanged` notifications, we need to actually respond to them. This behavior was defined in `Profiles::OnNavigatedTo()` in the `PropertyChanged()` handler. Funny enough, that code was still there, it just didn't do anything because it was trying to notify that `Profiles::CurrentXXX` changed. This is invalid because `CurrentXXX` got moved to `ProfileViewModel`. - The fix here was pretty easy. Just move the property changed handler to `ProfileViewModel`'s `PropertyChanged` handler that is defined in the ctor. Bug introduced in #11877 ✅ Profile termination behavior ✅ Bell notification style ✅ Text antialiasing ✅ Scrollbar visibility
Summary of the Pull Request
This fixes a bug where several settings would not show the reset button. The root cause of this issue is two fold:
CurrentXXXGETSET_BINDABLE_ENUM_SETTINGwas hooked up to the settings model profile object instead of the view model profile object. Since the settings model has noPropertyChangedsystem, any changes were directly being applied to the setting, but not notifying the view model (and thus, the view, by extension) to update themselves.PropertyChangednotificationsPropertyChangednotifications, we need to actually respond to them. This behavior was defined inProfiles::OnNavigatedTo()in thePropertyChanged()handler. Funny enough, that code was still there, it just didn't do anything because it was trying to notify thatProfiles::CurrentXXXchanged. This is invalid becauseCurrentXXXgot moved toProfileViewModel.ProfileViewModel'sPropertyChangedhandler that is defined in the ctor.References
Bug introduced in #11877
Validation Steps Performed
✅ Profile termination behavior
✅ Bell notification style
✅ Text antialiasing
✅ Scrollbar visibility