From bbdfb377fed969b475181d10bc7385366138c785 Mon Sep 17 00:00:00 2001 From: Pankaj Bhojwani Date: Fri, 22 Aug 2025 14:39:24 -0700 Subject: [PATCH] use action map's update id --- .../TerminalSettingsEditor/ActionsViewModel.cpp | 12 ++++++++++-- .../TerminalSettingsEditor/ActionsViewModel.h | 1 + .../TerminalSettingsEditor/ActionsViewModel.idl | 1 + 3 files changed, 12 insertions(+), 2 deletions(-) diff --git a/src/cascadia/TerminalSettingsEditor/ActionsViewModel.cpp b/src/cascadia/TerminalSettingsEditor/ActionsViewModel.cpp index f649ee3e74..5a7d69ae32 100644 --- a/src/cascadia/TerminalSettingsEditor/ActionsViewModel.cpp +++ b/src/cascadia/TerminalSettingsEditor/ActionsViewModel.cpp @@ -266,7 +266,7 @@ namespace winrt::Microsoft::Terminal::Settings::Editor::implementation _command.ActionAndArgs(newActionAndArgs); if (_IsNewCommand) { - _command.GenerateID(); + actionsPageVM.AttemptRegenerateCommandID(_command); } else if (!IsUserAction()) { @@ -447,7 +447,10 @@ namespace winrt::Microsoft::Terminal::Settings::Editor::implementation // for new commands, make sure we generate a new ID every time any arg value changes if (weak->_IsNewCommand) { - weak->_command.GenerateID(); + if (const auto actionsPageVM{ weak->_actionsPageVM.get() }) + { + actionsPageVM.AttemptRegenerateCommandID(weak->_command); + } } else if (!weak->IsUserAction()) { @@ -1259,6 +1262,11 @@ namespace winrt::Microsoft::Terminal::Settings::Editor::implementation _Settings.ActionMap().AddAction(newCommand, nullptr); } + void ActionsViewModel::AttemptRegenerateCommandID(const Model::Command& command) + { + _Settings.ActionMap().UpdateCommandID(command, {}); + } + void ActionsViewModel::_CmdVMEditRequestedHandler(const Editor::CommandViewModel& senderVM, const IInspectable& /*args*/) { CurrentCommand(senderVM); diff --git a/src/cascadia/TerminalSettingsEditor/ActionsViewModel.h b/src/cascadia/TerminalSettingsEditor/ActionsViewModel.h index ec999f276a..56eed67944 100644 --- a/src/cascadia/TerminalSettingsEditor/ActionsViewModel.h +++ b/src/cascadia/TerminalSettingsEditor/ActionsViewModel.h @@ -273,6 +273,7 @@ namespace winrt::Microsoft::Terminal::Settings::Editor::implementation void AttemptDeleteKeyChord(const Control::KeyChord& keys); void AttemptAddOrModifyKeyChord(const Editor::KeyChordViewModel& senderVM, winrt::hstring commandID, const Control::KeyChord& newKeys, const Control::KeyChord& oldKeys); void AttemptAddCopiedCommand(const Model::Command& newCommand); + void AttemptRegenerateCommandID(const Model::Command& command); Windows::Foundation::Collections::IMap AvailableShortcutActionsAndNames(); Windows::Foundation::Collections::IMap NameToActionMap(); diff --git a/src/cascadia/TerminalSettingsEditor/ActionsViewModel.idl b/src/cascadia/TerminalSettingsEditor/ActionsViewModel.idl index 0bda0f2dfd..bffa37e0f6 100644 --- a/src/cascadia/TerminalSettingsEditor/ActionsViewModel.idl +++ b/src/cascadia/TerminalSettingsEditor/ActionsViewModel.idl @@ -152,6 +152,7 @@ namespace Microsoft.Terminal.Settings.Editor void AttemptAddOrModifyKeyChord(KeyChordViewModel senderVM, String commandID, Microsoft.Terminal.Control.KeyChord newKeys, Microsoft.Terminal.Control.KeyChord oldKeys); void AttemptDeleteKeyChord(Microsoft.Terminal.Control.KeyChord keys); void AttemptAddCopiedCommand(Microsoft.Terminal.Settings.Model.Command newCommand); + void AttemptRegenerateCommandID(Microsoft.Terminal.Settings.Model.Command command); IObservableVector CommandList { get; }; void CmdListItemClicked(IInspectable sender, Windows.UI.Xaml.Controls.ItemClickEventArgs args);