Adjust arg position

This commit is contained in:
Kevin Zhang 2021-12-05 15:06:10 -06:00
parent d8eef69e21
commit 99a4a3cda8
2 changed files with 23 additions and 11 deletions

View file

@ -35,18 +35,21 @@ namespace Flow.Launcher.Plugin.SharedCommands
/// Opens search in a new browser. If no browser path is passed in then Chrome is used.
/// Leave browser path blank to use Chrome.
/// </summary>
public static void NewBrowserWindow(this string url, string browserPath = "", bool inPrivate = false, string privateArg = "")
public static void NewBrowserWindow(this string url, string browserPath = "", bool inPrivate = false, string privateArg = "")
{
browserPath = string.IsNullOrEmpty(browserPath) ? GetDefaultBrowserPath() : browserPath;
var browserExecutableName = browserPath?
.Split(new[] { Path.DirectorySeparatorChar }, StringSplitOptions.None)
.Last();
.Split(new[]
{
Path.DirectorySeparatorChar
}, StringSplitOptions.None)
.Last();
var browser = string.IsNullOrEmpty(browserExecutableName) ? "chrome" : browserPath;
// Internet Explorer will open url in new browser window, and does not take the --new-window parameter
var browserArguements = browserExecutableName == "iexplore.exe" ? url : "--new-window " + url + (inPrivate ? "" : privateArg);
var browserArguements = (browserExecutableName == "iexplore.exe" ? "" : "--new-window ") + (inPrivate ? $" {privateArg}" : "") + url;
var psi = new ProcessStartInfo
{
@ -61,7 +64,10 @@ namespace Flow.Launcher.Plugin.SharedCommands
}
catch (System.ComponentModel.Win32Exception)
{
Process.Start(new ProcessStartInfo { FileName = url, UseShellExecute = true });
Process.Start(new ProcessStartInfo
{
FileName = url, UseShellExecute = true
});
}
}
@ -72,13 +78,16 @@ namespace Flow.Launcher.Plugin.SharedCommands
{
browserPath = string.IsNullOrEmpty(browserPath) ? GetDefaultBrowserPath() : browserPath;
var psi = new ProcessStartInfo() { UseShellExecute = true };
var psi = new ProcessStartInfo()
{
UseShellExecute = true
};
try
{
if (!string.IsNullOrEmpty(browserPath))
{
psi.FileName = browserPath;
psi.Arguments = url + (inPrivate ? "" : privateArg);
psi.Arguments = (inPrivate ? $"{privateArg} " : "") + url;
}
else
{
@ -90,8 +99,11 @@ namespace Flow.Launcher.Plugin.SharedCommands
// This error may be thrown if browser path is incorrect
catch (System.ComponentModel.Win32Exception)
{
Process.Start(new ProcessStartInfo { FileName = url, UseShellExecute = true });
Process.Start(new ProcessStartInfo
{
FileName = url, UseShellExecute = true
});
}
}
}
}
}

View file

@ -218,10 +218,10 @@ namespace Flow.Launcher
if (browserInfo.OpenInTab)
{
SearchWeb.NewTabInBrowser(url, path, browserInfo.EnablePrivate, browserInfo.PrivateArg);
url.NewTabInBrowser(path, browserInfo.EnablePrivate, browserInfo.PrivateArg);
}else
{
SearchWeb.NewBrowserWindow(url, path, browserInfo.EnablePrivate, browserInfo.PrivateArg);
url.NewBrowserWindow(path, browserInfo.EnablePrivate, browserInfo.PrivateArg);
}
}