Repository: microsoft/terminal
File: src/cascadia/TerminalSettingsModel/ActionArgs.cpp (C++)

Code before:
                };
            }
            else
            {
                // "Decrease background opacity by {Opacity}%"
                return winrt::hstring{
                    fmt::format(std::wstring_view(RS_(L"DecreaseOpacityCommandKey")),
                                Opacity())
                };
            }
        }
        else
        {
            // "Set background opacity to {Opacity}%"
            return winrt::hstring{
                fmt::format(std::wstring_view(RS_(L"AdjustOpacityCommandKey")),
                            Opacity())
            };
        }
    }

    winrt::hstring SaveTaskArgs::GenerateName() const
    {
        std::wstring formattedString;

        if (!Name().empty() && !KeyChord().empty())
        {
            formattedString = fmt::format(L"Save Task commandline: {}, name: {}, keyChord {}", Commandline(), Name(), KeyChord());
        }
        else if (!Name().empty())
        {
            formattedString = fmt::format(L"Save Task commandline: {}, name: {}", Commandline(), Name());
        }
        else if (!KeyChord().empty())
        {
            formattedString = fmt::format(L"Save Task commandline: {}, keyChord {}", Commandline(), KeyChord());
        }
        else
        {
            formattedString = fmt::format(L"Save Task commandline: {}", Commandline());
        }

        return winrt::hstring{ formattedString };
     }

    static winrt::hstring _FormatColorString(const Control::SelectionColor& selectionColor)
    {
        if (!selectionColor)
        {
            return RS_(L"ColorSelection_defaultColor");
        }

Review comment (suggestion):
You may want to copy the pattern in `SplitPaneArgs::GenerateName`, which uses a stringstream, and then just adds each successive parameter to the stream (if the param is provided)

Code after:
        if (Relative())
        {
            if (Opacity() >= 0)
            {
                // "Increase background opacity by {Opacity}%"
                return winrt::hstring{
                    fmt::format(std::wstring_view(RS_(L"IncreaseOpacityCommandKey")),
                                Opacity())
                };
            }
            else
            {
                // "Decrease background opacity by {Opacity}%"
                return winrt::hstring{
                    fmt::format(std::wstring_view(RS_(L"DecreaseOpacityCommandKey")),
                                Opacity())
                };
            }
        }
        else
        {
            // "Set background opacity to {Opacity}%"
            return winrt::hstring{
                fmt::format(std::wstring_view(RS_(L"AdjustOpacityCommandKey")),
                            Opacity())
            };
        }
    }

    winrt::hstring SaveSnippetArgs::GenerateName() const
    {
        if (Feature_SaveSnippet::IsEnabled())
        {
            std::wstringstream ss;

            ss << RS_(L"SaveSnippetNamePrefix").c_str() << L" commandline: " << Commandline().c_str();

            if (!Name().empty())
            {
                ss << L", name: " << Name().c_str();
            }

            if (!KeyChord().empty())
            {
                ss << L", keyChord " << KeyChord().c_str();
            }

            return winrt::hstring{ ss.str() };
        }
        return L"";
    }