@@ -64,9 +64,9 @@ internal async Task<List<Result>> SearchAsync(Query query, CancellationToken tok
64
64
65
65
IAsyncEnumerable < SearchResult > searchResults ;
66
66
67
- bool isPathSearch = query . Search . IsLocationPathString ( ) || query . Search . StartsWith ( "%" ) ;
67
+ bool isPathSearch = query . Search . IsLocationPathString ( ) || IsEnvironmentVariableSearch ( query . Search ) ;
68
68
69
- string EngineName ;
69
+ string engineName ;
70
70
71
71
switch ( isPathSearch )
72
72
{
@@ -86,15 +86,15 @@ when ActionKeywordMatch(query, Settings.ActionKeyword.FileContentSearchActionKey
86
86
return EverythingContentSearchResult ( query ) ;
87
87
88
88
searchResults = Settings . ContentIndexProvider . ContentSearchAsync ( "" , query . Search , token ) ;
89
- EngineName = Enum . GetName ( Settings . ContentSearchEngine ) ;
89
+ engineName = Enum . GetName ( Settings . ContentSearchEngine ) ;
90
90
break ;
91
91
92
92
case false
93
93
when ActionKeywordMatch ( query , Settings . ActionKeyword . IndexSearchActionKeyword )
94
94
|| ActionKeywordMatch ( query , Settings . ActionKeyword . SearchActionKeyword ) :
95
95
96
96
searchResults = Settings . IndexProvider . SearchAsync ( query . Search , token ) ;
97
- EngineName = Enum . GetName ( Settings . IndexSearchEngine ) ;
97
+ engineName = Enum . GetName ( Settings . IndexSearchEngine ) ;
98
98
break ;
99
99
default :
100
100
return results . ToList ( ) ;
@@ -110,7 +110,7 @@ when ActionKeywordMatch(query, Settings.ActionKeyword.IndexSearchActionKeyword)
110
110
if ( e is OperationCanceledException )
111
111
return results . ToList ( ) ;
112
112
113
- throw new SearchException ( EngineName , e . Message , e ) ;
113
+ throw new SearchException ( engineName , e . Message , e ) ;
114
114
}
115
115
116
116
results . RemoveWhere ( r => Settings . IndexSearchExcludedSubdirectoryPaths . Any (
@@ -242,5 +242,12 @@ private bool UseWindowsIndexForDirectorySearch(string locationPath)
242
242
x => FilesFolders . ReturnPreviousDirectoryIfIncompleteString ( pathToDirectory ) . StartsWith ( x . Path , StringComparison . OrdinalIgnoreCase ) )
243
243
&& WindowsIndex . WindowsIndex . PathIsIndexed ( pathToDirectory ) ;
244
244
}
245
+
246
+ internal static bool IsEnvironmentVariableSearch ( string search )
247
+ {
248
+ return search . StartsWith ( "%" )
249
+ && search != "%%"
250
+ && ! search . Contains ( '\\ ' ) ;
251
+ }
245
252
}
246
253
}
0 commit comments