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

Code before:
            /* Cygwin */ L"/cygdrive/",
            /* MSYS2 */ L"/",
        };
        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);
            // Arithmetic overflow cannot occur here.
            pos += cchSingleQuoteEscape;
        }

        if (fullPath.size() >= 2 && fullPath.at(1) == L':')
        {
            // C:/foo/bar -> Cc/foo/bar
            fullPath.at(1) = til::tolower_ascii(fullPath.at(0));
            // Cc/foo/bar -> [PREFIX]c/foo/bar
            fullPath.replace(0, 1, s_pathPrefixes[static_cast<int>(translationStyle)]);
        }
        else if (translationStyle == PathTranslationStyle::WSL)
        {
            // Stripping the UNC name and distribution prefix only applies to WSL.
            static constexpr std::wstring_view wslPathPrefixes[] = { L"//wsl.localhost/", L"//wsl$/" };
            for (auto prefix : wslPathPrefixes)
            {
                if (til::starts_with(fullPath, prefix))
                {
                    if (const auto idx = fullPath.find(L'/', prefix.size()); idx != std::wstring::npos)
                    {
                        // //wsl.localhost/Ubuntu-18.04/foo/bar -> /foo/bar
                        fullPath.erase(0, idx);
                    }
                    else
                    {
                        // //wsl.localhost/Ubuntu-18.04 -> /
                        fullPath = L"/";
                    }
                    break;
                }

Review comment (suggestion):
This is entirely optional, but you could merge this with the following if condition if you wanted to:
```cpp
if (translationStyle != PathTranslationStyle::MinGW && fullPath.size() >= 2 && fullPath.at(1) == L':')
```

Code after:
            /* 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);
            // Arithmetic overflow cannot occur here.
            pos += cchSingleQuoteEscape;
        }

        if (translationStyle == PathTranslationStyle::MinGW)
        {
            return;
        }

        if (fullPath.size() >= 2 && fullPath.at(1) == L':')
        {
            // C:/foo/bar -> Cc/foo/bar
            fullPath.at(1) = til::tolower_ascii(fullPath.at(0));
            // Cc/foo/bar -> [PREFIX]c/foo/bar
            fullPath.replace(0, 1, s_pathPrefixes[static_cast<int>(translationStyle)]);
        }
        else if (translationStyle == PathTranslationStyle::WSL)
        {
            // Stripping the UNC name and distribution prefix only applies to WSL.
            static constexpr std::wstring_view wslPathPrefixes[] = { L"//wsl.localhost/", L"//wsl$/" };
            for (auto prefix : wslPathPrefixes)
            {
                if (til::starts_with(fullPath, prefix))
                {
                    if (const auto idx = fullPath.find(L'/', prefix.size()); idx != std::wstring::npos)
                    {
                        // //wsl.localhost/Ubuntu-18.04/foo/bar -> /foo/bar
                        fullPath.erase(0, idx);
                    }
                    else