@@ -68,7 +68,9 @@ internal async Task<List<Result>> SearchAsync(Query query, CancellationToken tok
68
68
69
69
IAsyncEnumerable < SearchResult > searchResults ;
70
70
71
- bool isPathSearch = query . Search . IsLocationPathString ( ) || IsEnvironmentVariableSearch ( query . Search ) ;
71
+ bool isPathSearch = query . Search . IsLocationPathString ( )
72
+ || EnvironmentVariables . IsEnvironmentVariableSearch ( query . Search )
73
+ || EnvironmentVariables . HasEnvironmentVar ( query . Search ) ;
72
74
73
75
string engineName ;
74
76
@@ -178,16 +180,16 @@ private async Task<List<Result>> PathSearchAsync(Query query, CancellationToken
178
180
179
181
// Query is a location path with a full environment variable, eg. %appdata%\somefolder\, c:\users\%USERNAME%\downloads
180
182
var needToExpand = EnvironmentVariables . HasEnvironmentVar ( querySearch ) ;
181
- var locationPath = needToExpand ? Environment . ExpandEnvironmentVariables ( querySearch ) : querySearch ;
183
+ var path = needToExpand ? Environment . ExpandEnvironmentVariables ( querySearch ) : querySearch ;
182
184
183
185
// Check that actual location exists, otherwise directory search will throw directory not found exception
184
- if ( ! FilesFolders . ReturnPreviousDirectoryIfIncompleteString ( locationPath ) . LocationExists ( ) )
186
+ if ( ! FilesFolders . ReturnPreviousDirectoryIfIncompleteString ( path ) . LocationExists ( ) )
185
187
return results . ToList ( ) ;
186
188
187
189
var useIndexSearch = Settings . IndexSearchEngine is Settings . IndexSearchEngineOption . WindowsIndex
188
- && UseWindowsIndexForDirectorySearch ( locationPath ) ;
190
+ && UseWindowsIndexForDirectorySearch ( path ) ;
189
191
190
- var retrievedDirectoryPath = FilesFolders . ReturnPreviousDirectoryIfIncompleteString ( locationPath ) ;
192
+ var retrievedDirectoryPath = FilesFolders . ReturnPreviousDirectoryIfIncompleteString ( path ) ;
191
193
192
194
results . Add ( retrievedDirectoryPath . EndsWith ( ":\\ " )
193
195
? ResultManager . CreateDriveSpaceDisplayResult ( retrievedDirectoryPath , query . ActionKeyword , useIndexSearch )
@@ -198,21 +200,21 @@ private async Task<List<Result>> PathSearchAsync(Query query, CancellationToken
198
200
199
201
IAsyncEnumerable < SearchResult > directoryResult ;
200
202
201
- var recursiveIndicatorIndex = query . Search . IndexOf ( '>' ) ;
203
+ var recursiveIndicatorIndex = path . IndexOf ( '>' ) ;
202
204
203
205
if ( recursiveIndicatorIndex > 0 && Settings . PathEnumerationEngine != Settings . PathEnumerationEngineOption . DirectEnumeration )
204
206
{
205
207
directoryResult =
206
208
Settings . PathEnumerator . EnumerateAsync (
207
- query . Search [ ..recursiveIndicatorIndex ] . Trim ( ) ,
208
- query . Search [ ( recursiveIndicatorIndex + 1 ) ..] ,
209
+ path [ ..recursiveIndicatorIndex ] . Trim ( ) ,
210
+ path [ ( recursiveIndicatorIndex + 1 ) ..] ,
209
211
true ,
210
212
token ) ;
211
213
212
214
}
213
215
else
214
216
{
215
- directoryResult = DirectoryInfoSearch . TopLevelDirectorySearch ( query , query . Search , token ) . ToAsyncEnumerable ( ) ;
217
+ directoryResult = DirectoryInfoSearch . TopLevelDirectorySearch ( query , path , token ) . ToAsyncEnumerable ( ) ;
216
218
}
217
219
218
220
if ( token . IsCancellationRequested )
@@ -245,12 +247,5 @@ private bool UseWindowsIndexForDirectorySearch(string locationPath)
245
247
x => FilesFolders . ReturnPreviousDirectoryIfIncompleteString ( pathToDirectory ) . StartsWith ( x . Path , StringComparison . OrdinalIgnoreCase ) )
246
248
&& WindowsIndex . WindowsIndex . PathIsIndexed ( pathToDirectory ) ;
247
249
}
248
-
249
- internal static bool IsEnvironmentVariableSearch ( string search )
250
- {
251
- return search . StartsWith ( "%" )
252
- && search != "%%"
253
- && ! search . Contains ( '\\ ' ) ;
254
- }
255
250
}
256
251
}
0 commit comments