use action map's update id

This commit is contained in:
Pankaj Bhojwani 2025-08-22 14:39:24 -07:00
parent 64dfb945b0
commit bbdfb377fe
3 changed files with 12 additions and 2 deletions

View File

@ -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);

View File

@ -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<Model::ShortcutAction, winrt::hstring> AvailableShortcutActionsAndNames();
Windows::Foundation::Collections::IMap<winrt::hstring, Model::ShortcutAction> NameToActionMap();

View File

@ -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<CommandViewModel> CommandList { get; };
void CmdListItemClicked(IInspectable sender, Windows.UI.Xaml.Controls.ItemClickEventArgs args);