mirror of
https://github.com/microsoft/terminal.git
synced 2026-05-21 14:27:22 +00:00
display name and generated id conflicts
This commit is contained in:
@@ -339,13 +339,18 @@ namespace winrt::Microsoft::Terminal::Settings::Editor::implementation
|
||||
});
|
||||
}
|
||||
|
||||
winrt::hstring CommandViewModel::DisplayName()
|
||||
{
|
||||
return _command.Name();
|
||||
}
|
||||
|
||||
winrt::hstring CommandViewModel::Name()
|
||||
{
|
||||
if (_IsNewCommand && !_command.HasName())
|
||||
if (_command.HasName())
|
||||
{
|
||||
return L"";
|
||||
return _command.Name();
|
||||
}
|
||||
return _command.Name();
|
||||
return L"";
|
||||
}
|
||||
|
||||
void CommandViewModel::Name(const winrt::hstring& newName)
|
||||
|
||||
@@ -28,7 +28,7 @@ namespace winrt::Microsoft::Terminal::Settings::Editor::implementation
|
||||
{
|
||||
bool operator()(const Editor::CommandViewModel& lhs, const Editor::CommandViewModel& rhs) const
|
||||
{
|
||||
return lhs.Name() < rhs.Name();
|
||||
return lhs.DisplayName() < rhs.DisplayName();
|
||||
}
|
||||
};
|
||||
|
||||
@@ -132,6 +132,7 @@ namespace winrt::Microsoft::Terminal::Settings::Editor::implementation
|
||||
const Windows::Foundation::Collections::IMap<Model::ShortcutAction, winrt::hstring>& availableShortcutActionsAndNames);
|
||||
void Initialize();
|
||||
|
||||
winrt::hstring DisplayName();
|
||||
winrt::hstring Name();
|
||||
void Name(const winrt::hstring& newName);
|
||||
|
||||
|
||||
@@ -68,6 +68,7 @@ namespace Microsoft.Terminal.Settings.Editor
|
||||
ActionArgsViewModel ActionArgsVM { get; };
|
||||
|
||||
// View-model specific
|
||||
String DisplayName { get; };
|
||||
Boolean IsNewCommand;
|
||||
|
||||
// UI side (command list page)
|
||||
|
||||
@@ -147,7 +147,7 @@
|
||||
<!-- Templates -->
|
||||
<DataTemplate x:Key="CommandTemplate"
|
||||
x:DataType="local:CommandViewModel">
|
||||
<ListViewItem AutomationProperties.Name="{x:Bind Name, Mode=OneWay}"
|
||||
<ListViewItem AutomationProperties.Name="{x:Bind DisplayName, Mode=OneWay}"
|
||||
Style="{StaticResource KeyBindingContainerStyle}">
|
||||
<Grid ColumnSpacing="8">
|
||||
<Grid.ColumnDefinitions>
|
||||
@@ -168,7 +168,7 @@
|
||||
<!-- Command Name -->
|
||||
<TextBlock Grid.Column="0"
|
||||
Style="{StaticResource KeyBindingNameTextBlockStyle}"
|
||||
Text="{x:Bind Name, Mode=OneWay}" />
|
||||
Text="{x:Bind DisplayName, Mode=OneWay}" />
|
||||
</Grid>
|
||||
</ListViewItem>
|
||||
</DataTemplate>
|
||||
|
||||
@@ -597,6 +597,17 @@ namespace winrt::Microsoft::Terminal::Settings::Model::implementation
|
||||
const auto newID = senderCmd.ID();
|
||||
if (newID != oldID)
|
||||
{
|
||||
if (const auto foundCmd{ _GetActionByID(newID) })
|
||||
{
|
||||
if (foundCmd.ActionAndArgs() != senderCmd.ActionAndArgs())
|
||||
{
|
||||
// we found a command that has the same ID as this one, but that command has different ActionAndArgs
|
||||
// this means that foundCommand's action and/or args have been changed since its ID was generated,
|
||||
// generate a new one for it
|
||||
// Note: this is recursive! Found command's ID being changed lands us back in here to resolve any cascading collisions
|
||||
foundCmd.GenerateID();
|
||||
}
|
||||
}
|
||||
// update _ActionMap with the ID change
|
||||
_ActionMap.erase(oldID);
|
||||
_ActionMap.emplace(newID, senderCmd);
|
||||
|
||||
@@ -134,8 +134,8 @@ namespace winrt::Microsoft::Terminal::Settings::Model::implementation
|
||||
auto actionAndArgsImpl{ winrt::get_self<implementation::ActionAndArgs>(_ActionAndArgs) };
|
||||
if (const auto generatedID = actionAndArgsImpl->GenerateID(); !generatedID.empty())
|
||||
{
|
||||
_ID = generatedID;
|
||||
_IDWasGenerated = true;
|
||||
ID(generatedID);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user