mirror of
https://github.com/microsoft/PowerToys.git
synced 2026-04-05 10:46:33 +02:00
[PT Run] Web search should use user's default browser (#17304)
* Web search does not use my default browser #16549 updated DefaultBrowserInfo logic to get program location from shell open command not icon location * Refactored DefaultBrowserInfo to start default browser with arguments specified in shell/open/command value for the browser. Added fallback to Microsoft Edge if no browser information available. #16549 Web search does not use my default browser * fixed comment #16549 Web search does not use my default browser
This commit is contained in:
@@ -63,7 +63,7 @@ namespace Community.PowerToys.Run.Plugin.WebSearch
|
||||
// empty non-global query:
|
||||
if (!AreResultsGlobal() && query.ActionKeyword == query.RawQuery)
|
||||
{
|
||||
string arguments = "\"? \"";
|
||||
string arguments = "? ";
|
||||
results.Add(new Result
|
||||
{
|
||||
Title = Properties.Resources.plugin_description.Remove(Description.Length - 1, 1),
|
||||
@@ -73,7 +73,7 @@ namespace Community.PowerToys.Run.Plugin.WebSearch
|
||||
ProgramArguments = arguments,
|
||||
Action = action =>
|
||||
{
|
||||
if (!Helper.OpenInShell(BrowserInfo.Path ?? BrowserInfo.MSEdgePath, arguments))
|
||||
if (!Helper.OpenCommandInShell(BrowserInfo.Path, BrowserInfo.ArgumentsPattern, arguments))
|
||||
{
|
||||
onPluginError();
|
||||
return false;
|
||||
@@ -105,37 +105,19 @@ namespace Community.PowerToys.Run.Plugin.WebSearch
|
||||
IcoPath = _iconPath,
|
||||
};
|
||||
|
||||
if (BrowserInfo.SupportsWebSearchByCmdLineArgument)
|
||||
string arguments = $"? {searchTerm}";
|
||||
|
||||
result.ProgramArguments = arguments;
|
||||
result.Action = action =>
|
||||
{
|
||||
string arguments = $"\"? {searchTerm}\"";
|
||||
|
||||
result.ProgramArguments = arguments;
|
||||
result.Action = action =>
|
||||
if (!Helper.OpenCommandInShell(BrowserInfo.Path, BrowserInfo.ArgumentsPattern, arguments))
|
||||
{
|
||||
if (!Helper.OpenInShell(BrowserInfo.Path ?? BrowserInfo.MSEdgePath, arguments))
|
||||
{
|
||||
onPluginError();
|
||||
return false;
|
||||
}
|
||||
onPluginError();
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
};
|
||||
}
|
||||
else
|
||||
{
|
||||
string url = string.Format(CultureInfo.InvariantCulture, BrowserInfo.SearchEngineUrl, searchTerm);
|
||||
|
||||
result.Action = action =>
|
||||
{
|
||||
if (!Helper.OpenInShell(url))
|
||||
{
|
||||
onPluginError();
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
};
|
||||
}
|
||||
return true;
|
||||
};
|
||||
|
||||
results.Add(result);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user