Skip to content

Commit b88a8c5

Browse files
eraseif
1 parent 6c6dd46 commit b88a8c5

File tree

1 file changed

+9
-16
lines changed

1 file changed

+9
-16
lines changed

src/cascadia/TerminalSettingsModel/ActionMap.cpp

Lines changed: 9 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -95,22 +95,17 @@ namespace winrt::Microsoft::Terminal::Settings::Model::implementation
9595
// - had an ID generated for them
9696
// - do not have a name/icon path
9797
// - have a hash that matches a command in the inbox actions
98-
std::unordered_set<winrt::hstring> IdsToRemove;
99-
for (const auto [userID, userCmd] : _ActionMap)
100-
{
101-
const auto userCmdImpl{ get_self<Command>(userCmd) };
102-
103-
// Note we don't need to explicitly check for the origin tag here since we only generate IDs for user actions,
104-
// so if we ID was generated it means this is a user action
105-
if (userCmdImpl->IdWasGenerated() && !userCmdImpl->HasName() && userCmd.IconPath().empty())
98+
std::erase_if(_ActionMap, [&](const auto& pair) {
99+
const auto userCmdImpl{ get_self<Command>(pair.second) };
100+
if (userCmdImpl->IdWasGenerated() && !userCmdImpl->HasName() && userCmdImpl->IconPath().empty())
106101
{
107-
const auto userActionHash = Hash(userCmd.ActionAndArgs());
102+
const auto userActionHash = Hash(userCmdImpl->ActionAndArgs());
108103
if (const auto inboxCmd = inboxActions.find(userActionHash); inboxCmd != inboxActions.end())
109104
{
110105
for (const auto& [key, cmdID] : _KeyMap)
111106
{
112107
// for any of our keys that point to the user action, point them to the inbox action instead
113-
if (cmdID == userID)
108+
if (cmdID == pair.first)
114109
{
115110
_KeyMap.insert_or_assign(key, inboxCmd->second.ID());
116111

@@ -119,14 +114,12 @@ namespace winrt::Microsoft::Terminal::Settings::Model::implementation
119114
}
120115
}
121116

122-
// add this ID to our set of IDs to remove
123-
IdsToRemove.insert(userID);
117+
// remove this pair
118+
return true;
124119
}
125120
}
126-
}
127-
128-
// now, remove the commands with the IDs we found
129-
std::erase_if(_ActionMap, [&IdsToRemove](const auto& pair) { return IdsToRemove.contains(pair.first); });
121+
return false;
122+
});
130123
}
131124

132125
bool ActionMap::FixUpsAppliedDuringLoad() const

0 commit comments

Comments
 (0)