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

Code before:
        if (!SwitcherMode())
        {
            return RS_(L"NextTabCommandKey");
        }

        const auto mode = SwitcherMode().Value() == TabSwitcherMode::MostRecentlyUsed ? L"most recently used" : L"in order";
        return winrt::hstring(fmt::format(L"{}, {}", RS_(L"NextTabCommandKey"), mode));
    }

    winrt::hstring RenameWindowArgs::GenerateName() const
    {
        // "Rename window to \"{_Name}\""
        // "Clear window name"
        if (!Name().empty())
        {
            return winrt::hstring{
                fmt::format(std::wstring_view(RS_(L"RenameWindowCommandKey")),
                            Name().c_str())
            };
        }
        return RS_(L"ResetWindowNameCommandKey");
    }

    winrt::hstring SearchForTextArgs::GenerateName() const
    {
        return winrt::hstring{
            fmt::format(std::wstring_view(RS_(L"SearchForTextCommandKey")),
                        Windows::Foundation::Uri(QueryUrl()).Domain().c_str())
        };
    }

    winrt::hstring GlobalSummonArgs::GenerateName() const
    {
        // GH#10210 - Is this action literally the same thing as the `quakeMode`
        // action? That has a special name.
        static const auto quakeModeArgs{ std::get<0>(GlobalSummonArgs::QuakeModeFromJson(Json::Value::null)) };
        if (quakeModeArgs.Equals(*this))
        {
            return RS_(L"QuakeModeCommandKey");
        }

        std::wstringstream ss;
        ss << std::wstring_view(RS_(L"GlobalSummonCommandKey"));

        // "Summon the Terminal window"
        // "Summon the Terminal window, name:\"{_Name}\""
        if (!Name().empty())
        {
            ss << L", name: ";
            ss << std::wstring_view(Name());
        }

Review comment (suggestion):
I'm confused… Isn't this supposed to be `if (QueryUrl())`?
(If it is: You can use `if (const auto queryUrl = QueryUrl())` here.)

Code after:
        if (!SwitcherMode())
        {
            return RS_(L"NextTabCommandKey");
        }

        const auto mode = SwitcherMode().Value() == TabSwitcherMode::MostRecentlyUsed ? L"most recently used" : L"in order";
        return winrt::hstring(fmt::format(L"{}, {}", RS_(L"NextTabCommandKey"), mode));
    }

    winrt::hstring RenameWindowArgs::GenerateName() const
    {
        // "Rename window to \"{_Name}\""
        // "Clear window name"
        if (!Name().empty())
        {
            return winrt::hstring{
                fmt::format(std::wstring_view(RS_(L"RenameWindowCommandKey")),
                            Name().c_str())
            };
        }
        return RS_(L"ResetWindowNameCommandKey");
    }

    winrt::hstring SearchForTextArgs::GenerateName() const
    {
        if (QueryUrl().empty())
        {
            // Return the default command name, because we'll just use the
            // default search engine for this.
            return RS_(L"SearchWebCommandKey");
        }

        try
        {
            return winrt::hstring{
                fmt::format(std::wstring_view(RS_(L"SearchForTextCommandKey")),
                            Windows::Foundation::Uri(QueryUrl()).Domain().c_str())
            };
        }
        CATCH_LOG();

        // We couldn't parse a URL out of this. Return no string at all, so that
        // we don't even put this into the command palette.
        return L"";
    }

    winrt::hstring GlobalSummonArgs::GenerateName() const
    {
        // GH#10210 - Is this action literally the same thing as the `quakeMode`
        // action? That has a special name.
        static const auto quakeModeArgs{ std::get<0>(GlobalSummonArgs::QuakeModeFromJson(Json::Value::null)) };