diff --git a/src/cascadia/TerminalSettingsEditor/Actions.cpp b/src/cascadia/TerminalSettingsEditor/Actions.cpp index 3476bb4d3ae..62ec0700b27 100644 --- a/src/cascadia/TerminalSettingsEditor/Actions.cpp +++ b/src/cascadia/TerminalSettingsEditor/Actions.cpp @@ -254,9 +254,9 @@ namespace winrt::Microsoft::Terminal::Settings::Editor::implementation void Actions::_ViewModelModifyKeyBindingHandler(const Editor::KeyBindingViewModel& senderVM, const Editor::ModifyKeyBindingEventArgs& args) { - // If the key chord was changed, - // update the settings model and view model appropriately - auto attemptRebindKeys = [=]() { + auto applyChangesToSettingsModel = [=]() { + // If the key chord was changed, + // update the settings model and view model appropriately if (args.OldKeys().Modifiers() != args.NewKeys().Modifiers() || args.OldKeys().Vkey() != args.NewKeys().Vkey()) { // update settings model @@ -266,11 +266,9 @@ namespace winrt::Microsoft::Terminal::Settings::Editor::implementation auto senderVMImpl{ get_self(senderVM) }; senderVMImpl->Keys(args.NewKeys()); } - }; - // If the action was changed, - // update the settings model and view model appropriately - auto attemptSetAction = [=]() { + // If the action was changed, + // update the settings model and view model appropriately if (args.OldActionName() != args.NewActionName()) { // convert the action's name into a view model. @@ -318,8 +316,7 @@ namespace winrt::Microsoft::Terminal::Settings::Editor::implementation senderVM.AcceptChangesFlyout(nullptr); // update settings model and view model - attemptRebindKeys(); - attemptSetAction(); + applyChangesToSettingsModel(); senderVM.ToggleEditMode(); }); @@ -337,8 +334,7 @@ namespace winrt::Microsoft::Terminal::Settings::Editor::implementation } // update settings model and view model - attemptRebindKeys(); - attemptSetAction(); + applyChangesToSettingsModel(); // We NEED to toggle the edit mode here, // so that if nothing changed, we still exit diff --git a/src/cascadia/TerminalSettingsEditor/Actions.h b/src/cascadia/TerminalSettingsEditor/Actions.h index a114fdfbb1c..e98cc915e6c 100644 --- a/src/cascadia/TerminalSettingsEditor/Actions.h +++ b/src/cascadia/TerminalSettingsEditor/Actions.h @@ -65,6 +65,12 @@ namespace winrt::Microsoft::Terminal::Settings::Editor::implementation // ProposedAction: the entry selected by the combo box; may disagree with the settings model. // CurrentAction: the combo box item that maps to the settings model value. // AvailableActions: the list of options in the combo box; both actions above must be in this list. + // NOTE: ProposedAction and CurrentAction may disagree mainly due to the "edit mode" system in place. + // Current Action serves as... + // 1 - a record of what to set ProposedAction to on a cancellation + // 2 - a form of translation between ProposedAction and the settings model + // We would also need an ActionMap reference to remove this, but this is a better separation + // of responsibilities. VIEW_MODEL_OBSERVABLE_PROPERTY(IInspectable, ProposedAction); VIEW_MODEL_OBSERVABLE_PROPERTY(hstring, CurrentAction); WINRT_PROPERTY(Windows::Foundation::Collections::IObservableVector, AvailableActions, nullptr);