@@ -70,7 +70,7 @@ internal static Result CreateFolderResult(string title, string subtitle, string
70
70
{
71
71
return new Result
72
72
{
73
- Title = title + addScoreInDebug ( score ) ,
73
+ Title = title + _addScoreInDebug ( score ) ,
74
74
IcoPath = path ,
75
75
SubTitle = subtitle ,
76
76
AutoCompleteText = GetAutoCompleteText ( title , query , path , ResultType . Folder ) ,
@@ -83,8 +83,7 @@ internal static Result CreateFolderResult(string title, string subtitle, string
83
83
{
84
84
try
85
85
{
86
- IncrementRunCounterIfNeeded ( path ) ;
87
- Context . API . OpenDirectory ( path ) ;
86
+ _openFolder ( path ) ;
88
87
return true ;
89
88
}
90
89
catch ( Exception ex )
@@ -133,7 +132,7 @@ internal static Result CreateDriveSpaceDisplayResult(string path, string actionK
133
132
ProgressBarColor = progressBarColor ,
134
133
Action = c =>
135
134
{
136
- Context . API . OpenDirectory ( path ) ;
135
+ _openFolder ( path ) ;
137
136
return true ;
138
137
} ,
139
138
TitleToolTip = path ,
@@ -194,7 +193,7 @@ internal static Result CreateOpenCurrentFolderResult(string path, string actionK
194
193
CopyText = folderPath ,
195
194
Action = _ =>
196
195
{
197
- Context . API . OpenDirectory ( folderPath ) ;
196
+ _openFolder ( folderPath ) ;
198
197
return true ;
199
198
} ,
200
199
ContextData = new SearchResult { Type = ResultType . Folder , FullPath = folderPath , WindowsIndexed = windowsIndexed }
@@ -207,7 +206,7 @@ internal static Result CreateFileResult(string filePath, Query query, int score
207
206
? new Result . PreviewInfo { IsMedia = true , PreviewImagePath = filePath , }
208
207
: Result . PreviewInfo . Default ;
209
208
210
- var title = Path . GetFileName ( filePath ) + addScoreInDebug ( score ) ;
209
+ var title = Path . GetFileName ( filePath ) + _addScoreInDebug ( score ) ;
211
210
212
211
var result = new Result
213
212
{
@@ -226,21 +225,15 @@ internal static Result CreateFileResult(string filePath, Query query, int score
226
225
// TODO Why do we check if file exists here, but not in the other if conditions?
227
226
if ( File . Exists ( filePath ) && c . SpecialKeyState . CtrlPressed && c . SpecialKeyState . ShiftPressed )
228
227
{
229
- // run the file as admin
230
- IncrementRunCounterIfNeeded ( filePath ) ;
231
- OpenFileAsAdmin ( filePath ) ;
228
+ _openFileAsAdmin ( filePath ) ;
232
229
}
233
230
else if ( c . SpecialKeyState . CtrlPressed )
234
231
{
235
- // open folder and select this file
236
- IncrementRunCounterIfNeeded ( filePath ) ;
237
- Context . API . OpenDirectory ( Path . GetDirectoryName ( filePath ) , filePath ) ;
232
+ _openFolder ( filePath , filePath ) ;
238
233
}
239
234
else
240
235
{
241
- // run the file
242
- IncrementRunCounterIfNeeded ( filePath ) ;
243
- FilesFolders . OpenPath ( filePath ) ;
236
+ _openFile ( filePath ) ;
244
237
}
245
238
}
246
239
catch ( Exception ex )
@@ -257,12 +250,37 @@ internal static Result CreateFileResult(string filePath, Query query, int score
257
250
return result ;
258
251
}
259
252
260
- private static void OpenFileAsAdmin ( string filePath )
253
+ public static bool IsMedia ( string extension )
254
+ {
255
+ if ( string . IsNullOrEmpty ( extension ) )
256
+ {
257
+ return false ;
258
+ }
259
+ else
260
+ {
261
+ return MediaExtensions . Contains ( extension . ToLowerInvariant ( ) ) ;
262
+ }
263
+ }
264
+
265
+ private static void _openFile ( string filePath )
266
+ {
267
+ _incrementEverythingRunCounterIfNeeded ( filePath ) ;
268
+ FilesFolders . OpenPath ( filePath ) ;
269
+ }
270
+
271
+ private static void _openFolder ( string folderPath , string fileNameOrFilePath = null )
272
+ {
273
+ _incrementEverythingRunCounterIfNeeded ( folderPath ) ;
274
+ Context . API . OpenDirectory ( Path . GetDirectoryName ( folderPath ) , fileNameOrFilePath ) ;
275
+ }
276
+
277
+ private static void _openFileAsAdmin ( string filePath )
261
278
{
262
279
_ = Task . Run ( ( ) =>
263
280
{
264
281
try
265
282
{
283
+ _incrementEverythingRunCounterIfNeeded ( filePath ) ;
266
284
Process . Start ( new ProcessStartInfo
267
285
{
268
286
FileName = filePath ,
@@ -278,25 +296,13 @@ private static void OpenFileAsAdmin(string filePath)
278
296
} ) ;
279
297
}
280
298
281
- private static void IncrementRunCounterIfNeeded ( string fileOrFolder )
299
+ private static void _incrementEverythingRunCounterIfNeeded ( string fileOrFolder )
282
300
{
283
301
if ( Settings . EverythingEnabled )
284
302
_ = Task . Run ( ( ) => EverythingApi . IncrementRunCounterAsync ( fileOrFolder ) ) ;
285
303
}
286
304
287
- public static bool IsMedia ( string extension )
288
- {
289
- if ( string . IsNullOrEmpty ( extension ) )
290
- {
291
- return false ;
292
- }
293
- else
294
- {
295
- return MediaExtensions . Contains ( extension . ToLowerInvariant ( ) ) ;
296
- }
297
- }
298
-
299
- private static string addScoreInDebug ( int score )
305
+ private static string _addScoreInDebug ( int score )
300
306
{
301
307
#if DEBUG
302
308
return $ " ➡️ { score } ";
0 commit comments