Skip to content

Commit 33f336c

Browse files
author
Benjamin Pasero
committed
Revert "Revert "Fix rawSearchService to handle maxResults=0 correctly""
This reverts commit 191ecb9.
1 parent 191ecb9 commit 33f336c

2 files changed

Lines changed: 20 additions & 1 deletion

File tree

src/vs/workbench/services/search/node/rawSearchService.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -254,7 +254,7 @@ export class SearchService implements IRawSearchService {
254254
const query = prepareQuery(config.filePattern || '');
255255
const compare = (matchA: IRawFileMatch, matchB: IRawFileMatch) => compareItemsByScore(matchA, matchB, query, true, FileMatchItemAccessor, scorerCache);
256256

257-
const maxResults = config.maxResults || Number.MAX_VALUE;
257+
const maxResults = typeof config.maxResults === 'number' ? config.maxResults : Number.MAX_VALUE;
258258
return arrays.topAsync(results, compare, maxResults, 10000, token);
259259
}
260260

src/vs/workbench/services/search/test/node/rawSearchService.test.ts

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -185,6 +185,25 @@ suite('RawSearchService', () => {
185185
assert.strictEqual(result.results.length, 1, 'Result');
186186
});
187187

188+
test('Handles maxResults=0 correctly', async function () {
189+
this.timeout(testTimeout);
190+
const service = new RawSearchService();
191+
192+
const query: IFileQuery = {
193+
type: QueryType.File,
194+
folderQueries: MULTIROOT_QUERIES,
195+
maxResults: 0,
196+
sortByScore: true,
197+
includePattern: {
198+
'*.txt': true,
199+
'*.js': true
200+
},
201+
};
202+
203+
const result = await DiskSearch.collectResultsFromEvent(service.fileSearch(query));
204+
assert.strictEqual(result.results.length, 0, 'Result');
205+
});
206+
188207
test('Multi-root with include pattern and exists', async function () {
189208
this.timeout(testTimeout);
190209
const service = new RawSearchService();

0 commit comments

Comments
 (0)