Repository: microsoft/terminal (language: cpp)

Issue:
A bunch of settings don't get duplicated
> How did the X macros for settings not help this?

Apparently we didnt use the macro for `CascadiaSettings::DuplicateProfile`!

`UseAtlasEngine`, `BellSound`, and `Elevate` are all missing from the duplicate. Connection type too, but that one's... tricky maybe. `Opacity` is duplicated, but it's not otherwise in the appearance macro. Uh oh.

_Originally posted by @zadjii-msft in https://github.com/microsoft/terminal/pull/12257#issuecomment-1022657199_


Discussion / hints:
We should really use the macros for these. `MTSM_PROFILE_SETTINGS` et. al.
So I've done a quick comparison between the macros and the duplicate method. Given the number of differences, I think I'm going to have to pass up on my offer of fixing this - I don't know the consequence of some of the properties not currently existing in the macro!

## Profile settings
### Missing from duplicate but in `MTSM_PROFILE_SETTINGS`
* `BellSound`
* `Elevate`
* `UseAtlasEngine`

### Missing from `MTSM_PROFILE_SETTINGS` but duplicated
* `Padding`
* `TabColor`

`ConnectionType` is duplicated, but special cased at the end (#12120)

## Font settings
All good 🎉 

## Appearance settings
### Missing from `MTSM_APPEARANCE_SETTINGS` but duplicated
* `Background`
* `CursorColor`
* `Foreground`
* `Opacity`
* `SelectionBackground`
@ianjoneill that's perfectly reasonable. As soon as I saw how the two had diverged I was a little worried about asking an external contributor to help with that mess 😅 

Thanks for the great write-up! This should make our lives a lot easier

Fix patch:
diff --git a/src/cascadia/TerminalSettingsModel/CascadiaSettings.cpp b/src/cascadia/TerminalSettingsModel/CascadiaSettings.cpp
index 7200479b00f..e3916eff51b 100644
--- a/src/cascadia/TerminalSettingsModel/CascadiaSettings.cpp
+++ b/src/cascadia/TerminalSettingsModel/CascadiaSettings.cpp
@@ -280,50 +280,43 @@ Model::Profile CascadiaSettings::DuplicateProfile(const Model::Profile& source)
     // If the source is hidden and the Settings UI creates a
     // copy of it we don't want the copy to be hidden as well.
     // --> Don't do DUPLICATE_SETTING_MACRO(Hidden);
-    DUPLICATE_SETTING_MACRO(Icon);
-    DUPLICATE_SETTING_MACRO(CloseOnExit);
-    DUPLICATE_SETTING_MACRO(TabTitle);
+
+#define DUPLICATE_PROFILE_SETTINGS(type, name, jsonKey, ...) \
+    DUPLICATE_SETTING_MACRO(name);
+
+    MTSM_PROFILE_SETTINGS(DUPLICATE_PROFILE_SETTINGS)
+#undef DUPLICATE_PROFILE_SETTINGS
+
+    // These two aren't in MTSM_PROFILE_SETTINGS because they're special
     DUPLICATE_SETTING_MACRO(TabColor);
-    DUPLICATE_SETTING_MACRO(SuppressApplicationTitle);
-    DUPLICATE_SETTING_MACRO(UseAcrylic);
-    DUPLICATE_SETTING_MACRO(ScrollState);
     DUPLICATE_SETTING_MACRO(Padding);
-    DUPLICATE_SETTING_MACRO(Commandline);
-    DUPLICATE_SETTING_MACRO(StartingDirectory);
-    DUPLICATE_SETTING_MACRO(AntialiasingMode);
-    DUPLICATE_SETTING_MACRO(HistorySize);
-    DUPLICATE_SETTING_MACRO(SnapOnInput);
-    DUPLICATE_SETTING_MACRO(AltGrAliasing);
-    DUPLICATE_SETTING_MACRO(BellStyle);
 
     {
         const auto font = source.FontInfo();
         const auto target = duplicated->FontInfo();
-        DUPLICATE_SETTING_MACRO_SUB(font, target, FontFace);
-        DUPLICATE_SETTING_MACRO_SUB(font, target, FontSize);
-        DUPLICATE_SETTING_MACRO_SUB(font, target, FontWeight);
-        DUPLICATE_SETTING_MACRO_SUB(font, target, FontFeatures);
-        DUPLICATE_SETTING_MACRO_SUB(font, target, FontAxes);
+
+#define DUPLICATE_FONT_SETTINGS(type, name, jsonKey, ...) \
+    DUPLICATE_SETTING_MACRO_SUB(font, target, name);
+
+        MTSM_FONT_SETTINGS(DUPLICATE_FONT_SETTINGS)
+#undef DUPLICATE_FONT_SETTINGS
     }
 
     {
         const auto appearance = source.DefaultAppearance();
         const auto target = duplicated->DefaultAppearance();
-        DUPLICATE_SETTING_MACRO_SUB(appearance, target, ColorSchemeName);
+
+#define DUPLICATE_APPEARANCE_SETTINGS(type, name, jsonKey, ...) \
+    DUPLICATE_SETTING_MACRO_SUB(appearance, target, name);
+
+        MTSM_APPEARANCE_SETTINGS(DUPLICATE_APPEARANCE_SETTINGS)
+#undef DUPLICATE_APPEARANCE_SETTINGS
+
+        // These aren't in MTSM_APPEARANCE_SETTINGS because they're special
         DUPLICATE_SETTING_MACRO_SUB(appearance, target, Foreground);
         DUPLICATE_SETTING_MACRO_SUB(appearance, target, Background);
         DUPLICATE_SETTING_MACRO_SUB(appearance, target, SelectionBackground);
         DUPLICATE_SETTING_MACRO_SUB(appearance, target, CursorColor);
-        DUPLICATE_SETTING_MACRO_SUB(appearance, target, PixelShaderPath);
-        DUPLICATE_SETTING_MACRO_SUB(appearance, target, IntenseTextStyle);
-        DUPLICATE_SETTING_MACRO_SUB(appearance, target, BackgroundImagePath);
-        DUPLICATE_SETTING_MACRO_SUB(appearance, target, BackgroundImageOpacity);
-        DUPLICATE_SETTING_MACRO_SUB(appearance, target, BackgroundImageStretchMode);
-        DUPLICATE_SETTING_MACRO_SUB(appearance, target, BackgroundImageAlignment);
-        DUPLICATE_SETTING_MACRO_SUB(appearance, target, RetroTerminalEffect);
-        DUPLICATE_SETTING_MACRO_SUB(appearance, target, CursorShape);
-        DUPLICATE_SETTING_MACRO_SUB(appearance, target, CursorHeight);
-        DUPLICATE_SETTING_MACRO_SUB(appearance, target, AdjustIndistinguishableColors);
         DUPLICATE_SETTING_MACRO_SUB(appearance, target, Opacity);
     }
 
diff --git a/src/cascadia/TerminalSettingsModel/MTSMSettings.h b/src/cascadia/TerminalSettingsModel/MTSMSettings.h
index 663fff126c4..f2f95a562f5 100644
--- a/src/cascadia/TerminalSettingsModel/MTSMSettings.h
+++ b/src/cascadia/TerminalSettingsModel/MTSMSettings.h
@@ -78,6 +78,15 @@ Author(s):
     X(Windows::Foundation::Collections::IVector<winrt::hstring>, BellSound, "bellSound", nullptr)                                                              \
     X(bool, Elevate, "elevate", false)
 
+// Intentionally omitted Profile settings:
+// * Name
+// * Updates
+// * Guid
+// * Hidden
+// * Source
+// * Padding: needs special FromJson parsing
+// * TabColor: is an optional setting, so needs to be set with INHERITABLE_NULLABLE_SETTING
+
 #define MTSM_FONT_SETTINGS(X)                                                          \
     X(hstring, FontFace, "face", DEFAULT_FONT_FACE)                                    \
     X(int32_t, FontSize, "size", DEFAULT_FONT_SIZE)                                    \
@@ -97,3 +106,7 @@ Author(s):
     X(hstring, BackgroundImagePath, "backgroundImage")                                                                                                             \
     X(Model::IntenseStyle, IntenseTextStyle, "intenseTextStyle", Model::IntenseStyle::Bright)                                                                      \
     X(bool, AdjustIndistinguishableColors, "adjustIndistinguishableColors", true)
+
+// Intentionally omitted Appearance settings:
+// * ForegroundKey, BackgroundKey, SelectionBackgroundKey, CursorColorKey: all optional colors
+// * Opacity: needs special parsing


Test patch: