add single quotes to WSL drag and drop (#16214)

Wrap single quotes to drag and dropped paths in WSL

## References and Relevant Issues
#15646  , #8109 

## Detailed Description of the Pull Request / Additional comments
First time contributor, from what I understand from reading #15646 and #8109 , issue is asking for single quotes added to a drag and dropped path always, regardless of whitespace and special characters, in WSL.

## Validation Steps Performed
Tested drag and drop changes in WSL and non WSL sources.

Closes #15646
This commit is contained in:
js324
2023-10-24 17:46:56 -04:00
committed by GitHub
parent d8c7719bfb
commit d0d3039963

View File

@@ -2908,7 +2908,9 @@ namespace winrt::Microsoft::Terminal::Control::implementation
// However, it's likely that the control layer may need to
// know about the source anyways in the future, to support
// GH#3158
if (_interactivity.ManglePathsForWsl())
const auto isWSL = _interactivity.ManglePathsForWsl();
if (isWSL)
{
std::replace(fullPath.begin(), fullPath.end(), L'\\', L'/');
@@ -2942,17 +2944,19 @@ namespace winrt::Microsoft::Terminal::Control::implementation
}
}
const auto containsSpaces = std::find(fullPath.begin(),
fullPath.end(),
L' ') != fullPath.end();
const auto quotesNeeded = isWSL || fullPath.find(L' ') != std::wstring::npos;
const auto quotesChar = isWSL ? L'\'' : L'"';
if (containsSpaces)
// Append fullPath and also wrap it in quotes if needed
if (quotesNeeded)
{
fullPath.insert(0, L"\"");
fullPath += L"\"";
allPathsString.push_back(quotesChar);
}
allPathsString.append(fullPath);
if (quotesNeeded)
{
allPathsString.push_back(quotesChar);
}
allPathsString += fullPath;
}
_pasteTextWithBroadcast(winrt::hstring{ allPathsString });