@@ -24,6 +24,12 @@ using namespace winrt::Microsoft::Terminal::Control;
24
24
#define SEND_INPUT_ARCH_SPECIFIC_ACTION_HASH " A020D2"
25
25
#endif
26
26
27
+ #if defined(_M_IX86)
28
+ #define SEND_INPUT2_ARCH_SPECIFIC_ACTION_HASH " 56911147"
29
+ #else
30
+ #define SEND_INPUT2_ARCH_SPECIFIC_ACTION_HASH " 58D1971"
31
+ #endif
32
+
27
33
namespace SettingsModelUnitTests
28
34
{
29
35
class SerializationTests : public JsonTestClass
@@ -49,6 +55,7 @@ namespace SettingsModelUnitTests
49
55
TEST_METHOD (GeneratedActionIDsEqualForIdenticalCommands);
50
56
TEST_METHOD (RoundtripLegacyToModernActions);
51
57
TEST_METHOD (RoundtripUserActionsSameAsInBoxAreRemoved);
58
+ TEST_METHOD (RoundtripActionsSameNameDifferentCommandsAreRetained);
52
59
TEST_METHOD (MultipleActionsAreCollapsed);
53
60
54
61
private:
@@ -1180,6 +1187,57 @@ namespace SettingsModelUnitTests
1180
1187
VERIFY_ARE_EQUAL (toString (newResult), toString (oldResult));
1181
1188
}
1182
1189
1190
+ void SerializationTests::RoundtripActionsSameNameDifferentCommandsAreRetained ()
1191
+ {
1192
+ static constexpr std::string_view oldSettingsJson{ R"(
1193
+ {
1194
+ "actions": [
1195
+ {
1196
+ "command": { "action": "sendInput", "input": "just some input" },
1197
+ "name": "mySendInput"
1198
+ },
1199
+ {
1200
+ "command": { "action": "sendInput", "input": "just some input 2" },
1201
+ "name": "mySendInput"
1202
+ }
1203
+ ]
1204
+ })" };
1205
+
1206
+ // There are two different actions with the same name,
1207
+ // ensure that both are kept but have different IDs generated for them
1208
+ static constexpr std::string_view newSettingsJson{ R"(
1209
+ {
1210
+ "actions": [
1211
+ {
1212
+ "name": "mySendInput",
1213
+ "command": { "action": "sendInput", "input": "just some input" },
1214
+ "id": "User.sendInput.)" SEND_INPUT_ARCH_SPECIFIC_ACTION_HASH R"( "
1215
+ },
1216
+ {
1217
+ "name": "mySendInput",
1218
+ "command": { "action": "sendInput", "input": "just some input 2" },
1219
+ "id": "User.sendInput.)" SEND_INPUT2_ARCH_SPECIFIC_ACTION_HASH R"( "
1220
+ }
1221
+ ]
1222
+ })" };
1223
+
1224
+ implementation::SettingsLoader loader{ oldSettingsJson, implementation::LoadStringResource (IDR_DEFAULTS) };
1225
+ loader.MergeInboxIntoUserSettings ();
1226
+ loader.FinalizeLayering ();
1227
+ VERIFY_IS_TRUE (loader.FixupUserSettings (), L" Validate that this will indicate we need to write them back to disk" );
1228
+ const auto settings = winrt::make_self<implementation::CascadiaSettings>(std::move (loader));
1229
+ const auto oldResult{ settings->ToJson () };
1230
+
1231
+ implementation::SettingsLoader newLoader{ newSettingsJson, implementation::LoadStringResource (IDR_DEFAULTS) };
1232
+ newLoader.MergeInboxIntoUserSettings ();
1233
+ newLoader.FinalizeLayering ();
1234
+ VERIFY_IS_FALSE (newLoader.FixupUserSettings (), L" Validate that there is no need to write back to disk" );
1235
+ const auto newSettings = winrt::make_self<implementation::CascadiaSettings>(std::move (newLoader));
1236
+ const auto newResult{ newSettings->ToJson () };
1237
+
1238
+ VERIFY_ARE_EQUAL (toString (newResult), toString (oldResult));
1239
+ }
1240
+
1183
1241
void SerializationTests::MultipleActionsAreCollapsed ()
1184
1242
{
1185
1243
static constexpr std::string_view oldSettingsJson{ R"(
0 commit comments