Skip to content

Commit

Permalink
even better, also get the ID from json
Browse files Browse the repository at this point in the history
  • Loading branch information
PankajBhojwani committed Mar 28, 2024
1 parent 10d1fc8 commit 71bf90f
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 9 deletions.
7 changes: 1 addition & 6 deletions src/cascadia/TerminalSettingsModel/ActionMap.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -804,12 +804,7 @@ namespace winrt::Microsoft::Terminal::Settings::Model::implementation
auto cmdImpl{ winrt::get_self<Command>(actionPair.second) };
if (cmdImpl->ID().empty())
{
auto actionAndArgsImpl{ winrt::get_self<ActionAndArgs>(cmdImpl->ActionAndArgs()) };
if (const auto generatedID = actionAndArgsImpl->GenerateID(); !generatedID.empty())
{
cmdImpl->ID(generatedID);
fixedUp = true;
}
fixedUp = cmdImpl->GenerateID() || fixedUp;
}
}
return fixedUp;
Expand Down
11 changes: 9 additions & 2 deletions src/cascadia/TerminalSettingsModel/Command.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -121,9 +121,15 @@ namespace winrt::Microsoft::Terminal::Settings::Model::implementation
return hstring{ _ID };
}

void Command::ID(hstring id)
bool Command::GenerateID()
{
_ID = id;
auto actionAndArgsImpl{ winrt::get_self<implementation::ActionAndArgs>(_ActionAndArgs) };
if (const auto generatedID = actionAndArgsImpl->GenerateID(); !generatedID.empty())
{
_ID = generatedID;
return true;
}
return false;
}

void Command::Name(const hstring& value)
Expand Down Expand Up @@ -276,6 +282,7 @@ namespace winrt::Microsoft::Terminal::Settings::Model::implementation
{
auto result = winrt::make_self<Command>();
result->_Origin = origin;
JsonUtils::GetValueForKey(json, IDKey, result->_ID);

auto nested = false;
JsonUtils::GetValueForKey(json, IterateOnKey, result->_IterateOn);
Expand Down
2 changes: 1 addition & 1 deletion src/cascadia/TerminalSettingsModel/Command.h
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ namespace winrt::Microsoft::Terminal::Settings::Model::implementation
void Name(const hstring& name);

hstring ID() const noexcept;
void ID(hstring id);
bool GenerateID();

Control::KeyChord Keys() const noexcept;
hstring KeyChordText() const noexcept;
Expand Down

0 comments on commit 71bf90f

Please sign in to comment.