Repository: microsoft/terminal
File: src/cascadia/TerminalApp/AppActionHandlers.cpp (C++)

Code before:
        args.Handled(true);
    }

    void TerminalPage::_HandleSearchForText(const IInspectable& /*sender*/,
                                            const ActionEventArgs& args)
    {
        if (args)
        {
            if (const auto& realArgs = args.ActionArgs().try_as<SearchForTextArgs>())
            {
                const auto queryUrl = realArgs.QueryUrl();
                if (const auto termControl{ _GetActiveControl() })
                {
                    if (termControl.HasSelection())
                    {
                        const auto selections{ termControl.SelectedText(true) };

                        // concatenate the selection into a single line
                        auto searchText = std::accumulate(selections.begin(), selections.end(), std::wstring());

                        // make it compact by replacing consecutive whitespaces with a single space
                        searchText = std::regex_replace(searchText, std::wregex(LR"(\s+)"), L" ");

                        if (realArgs.WrapWithQuotes())
                        {
                            searchText = L"\"" + searchText + L"\"";
                        }

                        const auto finalString = queryUrl + Windows::Foundation::Uri::EscapeComponent(searchText);
                        winrt::Microsoft::Terminal::Control::OpenHyperlinkEventArgs shortcut{ finalString };
                        _OpenHyperlinkHandler(termControl, shortcut);
                        args.Handled(true);
                    }
                }
            }
        }
    }

    void TerminalPage::_HandleGlobalSummon(const IInspectable& /*sender*/,
                                           const ActionEventArgs& args)
    {
        // Manually return false. These shouldn't ever get here, except for when
        // we fail to register for the global hotkey. In that case, returning
        // false here will let the underlying terminal still process the key, as
        // if it wasn't bound at all.
        args.Handled(false);
    }
    void TerminalPage::_HandleQuakeMode(const IInspectable& /*sender*/,
                                        const ActionEventArgs& args)
    {
        // Manually return false. These shouldn't ever get here, except for when

Review comment (suggestion):
nit: You can alternatively insert the quotes into the existing string
```cpp
searchText.insert(searchText.begin(), L'"');
searchText.push_back(L'"');
```

Code after:
        args.Handled(true);
    }

    void TerminalPage::_HandleSearchForText(const IInspectable& /*sender*/,
                                            const ActionEventArgs& args)
    {
        if (const auto termControl{ _GetActiveControl() })
        {
            if (termControl.HasSelection())
            {
                const auto selections{ termControl.SelectedText(true) };

                // concatenate the selection into a single line
                auto searchText = std::accumulate(selections.begin(), selections.end(), std::wstring());

                // make it compact by replacing consecutive whitespaces with a single space
                searchText = std::regex_replace(searchText, std::wregex(LR"(\s+)"), L" ");

                std::wstring queryUrl;
                if (args)
                {
                    if (const auto& realArgs = args.ActionArgs().try_as<SearchForTextArgs>())
                    {
                        queryUrl = realArgs.QueryUrl().c_str();
                    }
                }

                // use global default if query URL is unspecified
                if (queryUrl.empty())
                {
                    queryUrl = _settings.GlobalSettings().SearchWebDefaultQueryUrl().c_str();
                }

                constexpr std::wstring_view queryToken{ L"%s" };
                if (const auto pos{ queryUrl.find(queryToken) }; pos != std::wstring_view::npos)
                {
                    queryUrl.replace(pos, queryToken.length(), Windows::Foundation::Uri::EscapeComponent(searchText));
                }

                winrt::Microsoft::Terminal::Control::OpenHyperlinkEventArgs shortcut{ queryUrl };
                _OpenHyperlinkHandler(termControl, shortcut);
                args.Handled(true);
            }
        }
    }

    void TerminalPage::_HandleGlobalSummon(const IInspectable& /*sender*/,
                                           const ActionEventArgs& args)
    {
        // Manually return false. These shouldn't ever get here, except for when
        // we fail to register for the global hotkey. In that case, returning