Skip to content

Commit 98758f6

Browse files
committed
Fix opening web/url/bookmarks in new window and tab
Functionality broken after the upgrade
1 parent eb1844b commit 98758f6

File tree

2 files changed

+20
-14
lines changed

2 files changed

+20
-14
lines changed

Plugins/Wox.Plugin.WebSearch/SettingsControl.xaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@
2424
SelectedItem="{Binding Settings.SelectedSuggestion}"
2525
IsEnabled="{Binding ElementName=EnableSuggestion, Path=IsChecked}" Margin="10,3,10,10" />
2626
<!-- Not sure why binding IsEnabled directly to Settings.EnableWebSaerchSuggestion is not working -->
27-
<Label Content="Open search in:" Margin="40 3 0 8"/>
27+
<Label Content="Open search in:" Margin="30 3 0 8"/>
2828
<RadioButton Name="NewWindowBrowser" GroupName="OpenSearchBehaviour" Content="New window" Click="OnNewBrowserWindowClick" Margin="10" />
2929
<RadioButton Name="NewTabInBrowser" GroupName="OpenSearchBehaviour" Content="New tab" Click="OnNewTabClick" Margin="10" />
3030
</StackPanel>

Wox.Plugin/SharedCommands/SearchWeb.cs

Lines changed: 19 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ public static class SearchWeb
1111
/// Opens search in a new browser. If no browser path is passed in then Chrome is used.
1212
/// Leave browser path blank to use Chrome.
1313
/// </summary>
14-
public static void NewBrowserWindow(this string url, string browserPath)
14+
public static void NewBrowserWindow(this string url, string browserPath = "")
1515
{
1616
var browserExecutableName = browserPath?
1717
.Split(new[] { Path.DirectorySeparatorChar }, StringSplitOptions.None)
@@ -22,41 +22,47 @@ public static void NewBrowserWindow(this string url, string browserPath)
2222
// Internet Explorer will open url in new browser window, and does not take the --new-window parameter
2323
var browserArguements = browserExecutableName == "iexplore.exe" ? url : "--new-window " + url;
2424

25+
var psi = new ProcessStartInfo
26+
{
27+
FileName = browser,
28+
Arguments = browserArguements,
29+
UseShellExecute = true
30+
};
31+
2532
try
2633
{
27-
Process.Start(browser, browserArguements);
34+
Process.Start(psi);
2835
}
2936
catch (System.ComponentModel.Win32Exception)
3037
{
31-
var psi = new ProcessStartInfo
32-
{
33-
FileName = url,
34-
UseShellExecute = true
35-
};
36-
Process.Start(psi);
38+
Process.Start(new ProcessStartInfo { FileName = url, UseShellExecute = true });
3739
}
3840
}
3941

4042
/// <summary>
4143
/// Opens search as a tab in the default browser chosen in Windows settings.
4244
/// </summary>
43-
public static void NewTabInBrowser(this string url, string browserPath)
45+
public static void NewTabInBrowser(this string url, string browserPath = "")
4446
{
47+
var psi = new ProcessStartInfo() { UseShellExecute = true};
4548
try
4649
{
4750
if (!string.IsNullOrEmpty(browserPath))
4851
{
49-
Process.Start(browserPath, url);
52+
psi.FileName = browserPath;
53+
psi.Arguments = url;
5054
}
5155
else
5256
{
53-
Process.Start(url);
57+
psi.FileName = url;
5458
}
59+
60+
Process.Start(psi);
5561
}
56-
// This error may be thrown for Process.Start(browserPath, url)
62+
// This error may be thrown if browser path is incorrect
5763
catch (System.ComponentModel.Win32Exception)
5864
{
59-
Process.Start(url);
65+
Process.Start(new ProcessStartInfo { FileName = url, UseShellExecute = true });
6066
}
6167
}
6268
}

0 commit comments

Comments
 (0)