add a flag for wrapping in quotes too

This commit is contained in:
Mike Griese
2022-04-01 10:19:38 -05:00
parent a3192bef0f
commit 7be866690b
3 changed files with 10 additions and 3 deletions

View File

@@ -911,7 +911,12 @@ namespace winrt::TerminalApp::implementation
const auto selections{ termControl.SelectedText(true) };
if (selections.Size() == 1) // TODO! should theoretically be able to work for multiple lines of selection
{
const auto finalString = queryUrl + Windows::Foundation::Uri::EscapeComponent(selections.GetAt(0));
auto selectedText = selections.GetAt(0);
if (realArgs.WrapWithQuotes())
{
selectedText = L"\"" + selectedText + L"\"";
}
const auto finalString = queryUrl + Windows::Foundation::Uri::EscapeComponent(selectedText);
winrt::Microsoft::Terminal::Control::OpenHyperlinkEventArgs shortcut{ finalString };
_OpenHyperlinkHandler(termControl, shortcut);
args.Handled(true);

View File

@@ -202,8 +202,9 @@ private:
X(winrt::hstring, Name, "name", false, L"")
////////////////////////////////////////////////////////////////////////////////
#define SEARCH_FOR_TEXT_ARGS(X) \
X(winrt::hstring, QueryUrl, "queryUrl", false, L"")
#define SEARCH_FOR_TEXT_ARGS(X) \
X(winrt::hstring, QueryUrl, "queryUrl", false, L"") \
X(bool, WrapWithQuotes, "wrapWithQuotes", false, true)
//TODO! this should have some validation!
// Maybe in post though. Maybe at runtime make sure QueryUrl starts with "http:"

View File

@@ -330,6 +330,7 @@ namespace Microsoft.Terminal.Settings.Model
[default_interface] runtimeclass SearchForTextArgs : IActionArgs
{
String QueryUrl { get; };
Boolean WrapWithQuotes { get; };
};
[default_interface] runtimeclass GlobalSummonArgs : IActionArgs