66using System . Text ;
77using System . Threading . Tasks ;
88using Microsoft . Win32 ;
9- using Flow . Launcher . Infrastructure ;
109using Flow . Launcher . Plugin . Program . Logger ;
1110using Flow . Launcher . Plugin . SharedCommands ;
1211using Flow . Launcher . Plugin . SharedModels ;
@@ -73,7 +72,7 @@ public string UniqueIdentifier
7372 private const string ExeExtension = "exe" ;
7473 private string _uid = string . Empty ;
7574
76- private static readonly Win32 Default = new Win32 ( )
75+ private static readonly Win32 Default = new ( )
7776 {
7877 Name = string . Empty ,
7978 Description = string . Empty ,
@@ -92,7 +91,7 @@ private static MatchResult Match(string query, IReadOnlyCollection<string> candi
9291 if ( candidates . Count == 0 )
9392 return null ;
9493
95- var match = candidates . Select ( candidate => StringMatcher . FuzzySearch ( query , candidate ) )
94+ var match = candidates . Select ( candidate => Main . Context . API . FuzzySearch ( query , candidate ) )
9695 . MaxBy ( match => match . Score ) ;
9796
9897 return match ? . IsSearchPrecisionScoreMet ( ) ?? false ? match : null ;
@@ -112,14 +111,14 @@ public Result Result(string query, IPublicAPI api)
112111 resultName . Equals ( Description ) )
113112 {
114113 title = resultName ;
115- matchResult = StringMatcher . FuzzySearch ( query , resultName ) ;
114+ matchResult = Main . Context . API . FuzzySearch ( query , resultName ) ;
116115 }
117116 else
118117 {
119118 // Search in both
120119 title = $ "{ resultName } : { Description } ";
121- var nameMatch = StringMatcher . FuzzySearch ( query , resultName ) ;
122- var descriptionMatch = StringMatcher . FuzzySearch ( query , Description ) ;
120+ var nameMatch = Main . Context . API . FuzzySearch ( query , resultName ) ;
121+ var descriptionMatch = Main . Context . API . FuzzySearch ( query , Description ) ;
123122 if ( descriptionMatch . Score > nameMatch . Score )
124123 {
125124 for ( int i = 0 ; i < descriptionMatch . MatchData . Count ; i ++ )
@@ -219,27 +218,27 @@ public List<Result> ContextMenus(IPublicAPI api)
219218 {
220219 var contextMenus = new List < Result >
221220 {
222- new Result
221+ new ( )
223222 {
224223 Title = api . GetTranslation ( "flowlauncher_plugin_program_run_as_different_user" ) ,
225- Action = _ =>
224+ Action = c =>
226225 {
227226 var info = new ProcessStartInfo
228227 {
229228 FileName = FullPath , WorkingDirectory = ParentDirectory , UseShellExecute = true
230229 } ;
231230
232- Task . Run ( ( ) => Main . StartProcess ( ShellCommand . RunAsDifferentUser , info ) ) ;
231+ _ = Task . Run ( ( ) => Main . StartProcess ( ShellCommand . RunAsDifferentUser , info ) ) ;
233232
234233 return true ;
235234 } ,
236235 IcoPath = "Images/user.png" ,
237236 Glyph = new GlyphInfo ( FontFamily : "/Resources/#Segoe Fluent Icons" , Glyph : "\xe7ee " ) ,
238237 } ,
239- new Result
238+ new ( )
240239 {
241240 Title = api . GetTranslation ( "flowlauncher_plugin_program_run_as_administrator" ) ,
242- Action = _ =>
241+ Action = c =>
243242 {
244243 var info = new ProcessStartInfo
245244 {
@@ -249,14 +248,14 @@ public List<Result> ContextMenus(IPublicAPI api)
249248 UseShellExecute = true
250249 } ;
251250
252- Task . Run ( ( ) => Main . StartProcess ( Process . Start , info ) ) ;
251+ _ = Task . Run ( ( ) => Main . StartProcess ( Process . Start , info ) ) ;
253252
254253 return true ;
255254 } ,
256255 IcoPath = "Images/cmd.png" ,
257256 Glyph = new GlyphInfo ( FontFamily : "/Resources/#Segoe Fluent Icons" , Glyph : "\xe7ef " ) ,
258257 } ,
259- new Result
258+ new ( )
260259 {
261260 Title = api . GetTranslation ( "flowlauncher_plugin_program_open_containing_folder" ) ,
262261 Action = _ =>
@@ -296,7 +295,7 @@ public override string ToString()
296295 return Name ;
297296 }
298297
299- private static List < FileSystemWatcher > Watchers = new List < FileSystemWatcher > ( ) ;
298+ private static readonly List < FileSystemWatcher > Watchers = new ( ) ;
300299
301300 private static Win32 Win32Program ( string path )
302301 {
@@ -402,7 +401,7 @@ private static Win32 UrlProgram(string path, string[] protocols)
402401 var data = parser . ReadFile ( path ) ;
403402 var urlSection = data [ "InternetShortcut" ] ;
404403 var url = urlSection ? [ "URL" ] ;
405- if ( String . IsNullOrEmpty ( url ) )
404+ if ( string . IsNullOrEmpty ( url ) )
406405 {
407406 return program ;
408407 }
@@ -418,12 +417,12 @@ private static Win32 UrlProgram(string path, string[] protocols)
418417 }
419418
420419 var iconPath = urlSection ? [ "IconFile" ] ;
421- if ( ! String . IsNullOrEmpty ( iconPath ) )
420+ if ( ! string . IsNullOrEmpty ( iconPath ) )
422421 {
423422 program . IcoPath = iconPath ;
424423 }
425424 }
426- catch ( Exception e )
425+ catch ( Exception )
427426 {
428427 // Many files do not have the required fields, so no logging is done.
429428 }
@@ -474,7 +473,7 @@ private static string Extension(string path)
474473 var extension = Path . GetExtension ( path ) ? . ToLowerInvariant ( ) ;
475474 if ( ! string . IsNullOrEmpty ( extension ) )
476475 {
477- return extension . Substring ( 1 ) ; // remove dot
476+ return extension [ 1 .. ] ; // remove dot
478477 }
479478 else
480479 {
@@ -785,7 +784,7 @@ public static void WatchProgramUpdate(Settings settings)
785784 _ = Task . Run ( MonitorDirectoryChangeAsync ) ;
786785 }
787786
788- private static Channel < byte > indexQueue = Channel . CreateBounded < byte > ( 1 ) ;
787+ private static readonly Channel < byte > indexQueue = Channel . CreateBounded < byte > ( 1 ) ;
789788
790789 public static async Task MonitorDirectoryChangeAsync ( )
791790 {
0 commit comments