@@ -59,6 +59,7 @@ public static async ValueTask<bool> IsEverythingRunningAsync(CancellationToken t
59
59
{
60
60
EverythingApiDllImport . Everything_GetMajorVersion ( ) ;
61
61
var result = EverythingApiDllImport . Everything_GetLastError ( ) != StateCode . IPCError ;
62
+
62
63
return result ;
63
64
}
64
65
finally
@@ -67,6 +68,8 @@ public static async ValueTask<bool> IsEverythingRunningAsync(CancellationToken t
67
68
}
68
69
}
69
70
71
+ const int ScoreScaleFactor = 5 ;
72
+
70
73
/// <summary>
71
74
/// Searches the specified key word and reset the everything API afterwards
72
75
/// </summary>
@@ -115,7 +118,7 @@ public static async IAsyncEnumerable<SearchResult> SearchAsync(EverythingSearchO
115
118
116
119
EverythingApiDllImport . Everything_SetSort ( option . SortOption ) ;
117
120
EverythingApiDllImport . Everything_SetMatchPath ( option . IsFullPathSearch ) ;
118
-
121
+
119
122
if ( option . SortOption == SortOption . RUN_COUNT_DESCENDING )
120
123
{
121
124
EverythingApiDllImport . Everything_SetRequestFlags ( EVERYTHING_REQUEST_FULL_PATH_AND_FILE_NAME | EVERYTHING_REQUEST_RUN_COUNT ) ;
@@ -132,10 +135,13 @@ public static async IAsyncEnumerable<SearchResult> SearchAsync(EverythingSearchO
132
135
if ( ! EverythingApiDllImport . Everything_QueryW ( true ) )
133
136
{
134
137
CheckAndThrowExceptionOnError ( ) ;
138
+
135
139
yield break ;
136
140
}
137
141
138
- for ( var idx = 0 ; idx < EverythingApiDllImport . Everything_GetNumResults ( ) ; ++ idx )
142
+ var numResults = EverythingApiDllImport . Everything_GetNumResults ( ) ;
143
+
144
+ for ( var idx = 0 ; idx < numResults ; ++ idx )
139
145
{
140
146
if ( token . IsCancellationRequested )
141
147
{
@@ -151,7 +157,8 @@ public static async IAsyncEnumerable<SearchResult> SearchAsync(EverythingSearchO
151
157
Type = EverythingApiDllImport . Everything_IsFolderResult ( idx ) ? ResultType . Folder :
152
158
EverythingApiDllImport . Everything_IsFileResult ( idx ) ? ResultType . File :
153
159
ResultType . Volume ,
154
- Score = ( int ) EverythingApiDllImport . Everything_GetResultRunCount ( ( uint ) idx )
160
+ Score = ( option . SortOption is SortOption . RUN_COUNT_DESCENDING ? ( int ) EverythingApiDllImport . Everything_GetResultRunCount ( ( uint ) idx ) : 0 ) * ScoreScaleFactor ,
161
+ WindowsIndexed = false
155
162
} ;
156
163
157
164
yield return result ;
@@ -192,6 +199,7 @@ private static void CheckAndThrowExceptionOnError()
192
199
public static async Task IncrementRunCounterAsync ( string fileOrFolder )
193
200
{
194
201
await _semaphore . WaitAsync ( TimeSpan . FromSeconds ( 1 ) ) ;
202
+
195
203
try
196
204
{
197
205
_ = EverythingApiDllImport . Everything_IncRunCountFromFileName ( fileOrFolder ) ;
0 commit comments