Skip to content

Commit d0d3039

Browse files
authored
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
1 parent d8c7719 commit d0d3039

File tree

1 file changed

+13
-9
lines changed

1 file changed

+13
-9
lines changed

src/cascadia/TerminalControl/TermControl.cpp

+13-9
Original file line numberDiff line numberDiff line change
@@ -2908,7 +2908,9 @@ namespace winrt::Microsoft::Terminal::Control::implementation
29082908
// However, it's likely that the control layer may need to
29092909
// know about the source anyways in the future, to support
29102910
// GH#3158
2911-
if (_interactivity.ManglePathsForWsl())
2911+
const auto isWSL = _interactivity.ManglePathsForWsl();
2912+
2913+
if (isWSL)
29122914
{
29132915
std::replace(fullPath.begin(), fullPath.end(), L'\\', L'/');
29142916

@@ -2942,17 +2944,19 @@ namespace winrt::Microsoft::Terminal::Control::implementation
29422944
}
29432945
}
29442946

2945-
const auto containsSpaces = std::find(fullPath.begin(),
2946-
fullPath.end(),
2947-
L' ') != fullPath.end();
2947+
const auto quotesNeeded = isWSL || fullPath.find(L' ') != std::wstring::npos;
2948+
const auto quotesChar = isWSL ? L'\'' : L'"';
29482949

2949-
if (containsSpaces)
2950+
// Append fullPath and also wrap it in quotes if needed
2951+
if (quotesNeeded)
29502952
{
2951-
fullPath.insert(0, L"\"");
2952-
fullPath += L"\"";
2953+
allPathsString.push_back(quotesChar);
2954+
}
2955+
allPathsString.append(fullPath);
2956+
if (quotesNeeded)
2957+
{
2958+
allPathsString.push_back(quotesChar);
29532959
}
2954-
2955-
allPathsString += fullPath;
29562960
}
29572961

29582962
_pasteTextWithBroadcast(winrt::hstring{ allPathsString });

0 commit comments

Comments
 (0)