Repository: microsoft/terminal
File: src/cascadia/TerminalControl/TermControl.cpp (C++)

Code before:
    {
        return;
    }

    bool result;
    if (visible)
    {
        std::ignore = inputPane->TryShow(&result);
    }
    else
    {
        std::ignore = inputPane->TryHide(&result);
    }
}

static Microsoft::Console::TSF::Handle& GetTSFHandle()
{
    // NOTE: If we ever go back to 1 thread per 1 window,
    // you need to swap the `static` with a `thread_local`.
    static auto s_tsf = ::Microsoft::Console::TSF::Handle::Create();
    return s_tsf;
}

namespace winrt::Microsoft::Terminal::Control::implementation
{
    Windows::UI::ViewManagement::AccessibilitySettings TermControl::_accessibilitySettings{};

    static void _translatePathInPlace(std::wstring& fullPath, PathTranslationStyle translationStyle)
    {
        static constexpr wil::zwstring_view s_pathPrefixes[] = {
            {},
            /* WSL */ L"/mnt/",
            /* Cygwin */ L"/cygdrive/",
            /* MSYS2 */ L"/",
            /* MinGW */ {},
        };
        static constexpr wil::zwstring_view sSingleQuoteEscape = L"'\\''";
        static constexpr auto cchSingleQuoteEscape = sSingleQuoteEscape.size();

        if (translationStyle == PathTranslationStyle::None)
        {
            return;
        }

        // All of the other path translation modes current result in /-delimited paths
        std::replace(fullPath.begin(), fullPath.end(), L'\\', L'/');

        // Escape single quotes, assuming translated paths are always quoted by a pair of single quotes.
        size_t pos = 0;
        while ((pos = fullPath.find(L'\'', pos)) != std::wstring::npos)
        {

Review comment (bug):
ah, I just realized. We can't do this. We cannot have static globals that _instantiate WinRT classes_ during DLL load time.

This will break the safety of DLL initialization, _and_ it will break the initialization of TermControl.dll on earlier versions of Windows (like the one VS uses) even if they aren't actually using TermControl itself.

Code after:
    {
        return;
    }

    bool result;
    if (visible)
    {
        std::ignore = inputPane->TryShow(&result);
    }
    else
    {
        std::ignore = inputPane->TryHide(&result);
    }
}

static Microsoft::Console::TSF::Handle& GetTSFHandle()
{
    // NOTE: If we ever go back to 1 thread per 1 window,
    // you need to swap the `static` with a `thread_local`.
    static auto s_tsf = ::Microsoft::Console::TSF::Handle::Create();
    return s_tsf;
}

namespace winrt::Microsoft::Terminal::Control::implementation
{
    static void _translatePathInPlace(std::wstring& fullPath, PathTranslationStyle translationStyle)
    {
        static constexpr wil::zwstring_view s_pathPrefixes[] = {
            {},
            /* WSL */ L"/mnt/",
            /* Cygwin */ L"/cygdrive/",
            /* MSYS2 */ L"/",
            /* MinGW */ {},
        };
        static constexpr wil::zwstring_view sSingleQuoteEscape = L"'\\''";
        static constexpr auto cchSingleQuoteEscape = sSingleQuoteEscape.size();

        if (translationStyle == PathTranslationStyle::None)
        {
            return;
        }

        // All of the other path translation modes current result in /-delimited paths
        std::replace(fullPath.begin(), fullPath.end(), L'\\', L'/');

        // Escape single quotes, assuming translated paths are always quoted by a pair of single quotes.
        size_t pos = 0;
        while ((pos = fullPath.find(L'\'', pos)) != std::wstring::npos)
        {
            // ' -> '\'' (for POSIX shell)
            fullPath.replace(pos, 1, sSingleQuoteEscape);