Skip to content

Commit 32ae3a1

Browse files
committed
Improve code quality
1 parent 524fb6a commit 32ae3a1

File tree

1 file changed

+8
-7
lines changed

1 file changed

+8
-7
lines changed

Flow.Launcher.Plugin/SharedCommands/SearchWeb.cs

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,9 @@
1-
using Microsoft.Win32;
2-
using System;
1+
using System;
2+
using System.ComponentModel;
33
using System.Diagnostics;
44
using System.IO;
55
using System.Linq;
6+
using Microsoft.Win32;
67

78
namespace Flow.Launcher.Plugin.SharedCommands
89
{
@@ -13,7 +14,7 @@ public static class SearchWeb
1314
{
1415
private static string GetDefaultBrowserPath()
1516
{
16-
string name = string.Empty;
17+
var name = string.Empty;
1718
try
1819
{
1920
using var regDefault = Registry.CurrentUser.OpenSubKey("Software\\Microsoft\\Windows\\Shell\\Associations\\UrlAssociations\\http\\UserChoice", false);
@@ -23,8 +24,7 @@ private static string GetDefaultBrowserPath()
2324
name = regKey.GetValue(null).ToString().ToLower().Replace("\"", "");
2425

2526
if (!name.EndsWith("exe"))
26-
name = name.Substring(0, name.LastIndexOf(".exe") + 4);
27-
27+
name = name[..(name.LastIndexOf(".exe") + 4)];
2828
}
2929
catch
3030
{
@@ -65,7 +65,8 @@ public static void OpenInBrowserWindow(this string url, string browserPath = "",
6565
{
6666
Process.Start(psi)?.Dispose();
6767
}
68-
catch (System.ComponentModel.Win32Exception)
68+
// This error may be thrown if browser path is incorrect
69+
catch (Win32Exception)
6970
{
7071
Process.Start(new ProcessStartInfo
7172
{
@@ -100,7 +101,7 @@ public static void OpenInBrowserTab(this string url, string browserPath = "", bo
100101
Process.Start(psi)?.Dispose();
101102
}
102103
// This error may be thrown if browser path is incorrect
103-
catch (System.ComponentModel.Win32Exception)
104+
catch (Win32Exception)
104105
{
105106
Process.Start(new ProcessStartInfo
106107
{

0 commit comments

Comments
 (0)