@@ -64,9 +64,9 @@ internal async Task<List<Result>> SearchAsync(Query query, CancellationToken tok
6464
6565 IAsyncEnumerable < SearchResult > searchResults ;
6666
67- bool isPathSearch = query . Search . IsLocationPathString ( ) || query . Search . StartsWith ( "%" ) ;
67+ bool isPathSearch = query . Search . IsLocationPathString ( ) || IsEnvironmentVariableSearch ( query . Search ) ;
6868
69- string EngineName ;
69+ string engineName ;
7070
7171 switch ( isPathSearch )
7272 {
@@ -86,15 +86,15 @@ when ActionKeywordMatch(query, Settings.ActionKeyword.FileContentSearchActionKey
8686 return EverythingContentSearchResult ( query ) ;
8787
8888 searchResults = Settings . ContentIndexProvider . ContentSearchAsync ( "" , query . Search , token ) ;
89- EngineName = Enum . GetName ( Settings . ContentSearchEngine ) ;
89+ engineName = Enum . GetName ( Settings . ContentSearchEngine ) ;
9090 break ;
9191
9292 case false
9393 when ActionKeywordMatch ( query , Settings . ActionKeyword . IndexSearchActionKeyword )
9494 || ActionKeywordMatch ( query , Settings . ActionKeyword . SearchActionKeyword ) :
9595
9696 searchResults = Settings . IndexProvider . SearchAsync ( query . Search , token ) ;
97- EngineName = Enum . GetName ( Settings . IndexSearchEngine ) ;
97+ engineName = Enum . GetName ( Settings . IndexSearchEngine ) ;
9898 break ;
9999 default :
100100 return results . ToList ( ) ;
@@ -110,7 +110,7 @@ when ActionKeywordMatch(query, Settings.ActionKeyword.IndexSearchActionKeyword)
110110 if ( e is OperationCanceledException )
111111 return results . ToList ( ) ;
112112
113- throw new SearchException ( EngineName , e . Message , e ) ;
113+ throw new SearchException ( engineName , e . Message , e ) ;
114114 }
115115
116116 results . RemoveWhere ( r => Settings . IndexSearchExcludedSubdirectoryPaths . Any (
@@ -242,5 +242,12 @@ private bool UseWindowsIndexForDirectorySearch(string locationPath)
242242 x => FilesFolders . ReturnPreviousDirectoryIfIncompleteString ( pathToDirectory ) . StartsWith ( x . Path , StringComparison . OrdinalIgnoreCase ) )
243243 && WindowsIndex . WindowsIndex . PathIsIndexed ( pathToDirectory ) ;
244244 }
245+
246+ internal static bool IsEnvironmentVariableSearch ( string search )
247+ {
248+ return search . StartsWith ( "%" )
249+ && search != "%%"
250+ && ! search . Contains ( '\\ ' ) ;
251+ }
245252 }
246253}
0 commit comments