diff --git a/src/vs/workbench/services/search/node/fileSearch.ts b/src/vs/workbench/services/search/node/fileSearch.ts index 8a4da30f57df02275ec1db80a123a3584e76dfaf..e4d0dbbc75b8cd4421502bfa88e038ab28fae0a3 100644 --- a/src/vs/workbench/services/search/node/fileSearch.ts +++ b/src/vs/workbench/services/search/node/fileSearch.ts @@ -213,7 +213,7 @@ export class FileWalker { onMessage({ message: rgCmd }); this.cmdResultCount = 0; - this.collectStdout(cmd, 'utf8', onMessage, (err: Error, stdout?: string, last?: boolean) => { + this.collectStdout(cmd, 'utf8', onMessage, (err: Error | null, stdout?: string, last?: boolean) => { if (err) { done(err); return; @@ -300,7 +300,7 @@ export class FileWalker { */ readStdout(cmd: childProcess.ChildProcess, encoding: string, cb: (err: Error | null, stdout?: string) => void): void { let all = ''; - this.collectStdout(cmd, encoding, () => { }, (err: Error, stdout?: string, last?: boolean) => { + this.collectStdout(cmd, encoding, () => { }, (err: Error | null, stdout?: string, last?: boolean) => { if (err) { cb(err); return; @@ -547,12 +547,9 @@ export class FileWalker { return clb(null, undefined); }); }); - }, (error: Error[]): void => { - if (error) { - error = arrays.coalesce(error); // find any error by removing null values first - } - - return done(error && error.length > 0 ? error[0] : undefined); + }, (error: Array | null): void => { + const filteredErrors = error ? arrays.coalesce(error) : error; // find any error by removing null values first + return done(filteredErrors && filteredErrors.length > 0 ? filteredErrors[0] : undefined); }); } @@ -622,8 +619,8 @@ export class Engine implements ISearchEngine { this.walker = new FileWalker(config); } - search(onResult: (result: IRawFileMatch) => void, onProgress: (progress: IProgressMessage) => void, done: (error: Error, complete: ISearchEngineSuccess) => void): void { - this.walker.walk(this.folderQueries, this.extraFiles, onResult, onProgress, (err: Error, isLimitHit: boolean) => { + search(onResult: (result: IRawFileMatch) => void, onProgress: (progress: IProgressMessage) => void, done: (error: Error | null, complete: ISearchEngineSuccess) => void): void { + this.walker.walk(this.folderQueries, this.extraFiles, onResult, onProgress, (err: Error | null, isLimitHit: boolean) => { done(err, { limitHit: isLimitHit, stats: this.walker.getStats() diff --git a/src/vs/workbench/test/browser/api/extHostDiagnostics.test.ts b/src/vs/workbench/test/browser/api/extHostDiagnostics.test.ts index 4930298a3846fcd8d4d6157edc27522baaa60f62..f0b4a8edc253275f6ae46e193c92f6055e74e272 100644 --- a/src/vs/workbench/test/browser/api/extHostDiagnostics.test.ts +++ b/src/vs/workbench/test/browser/api/extHostDiagnostics.test.ts @@ -12,6 +12,7 @@ import { IMarkerData, MarkerSeverity } from 'vs/platform/markers/common/markers' import { mock } from 'vs/workbench/test/browser/api/mock'; import { Emitter, Event } from 'vs/base/common/event'; import { NullLogService } from 'vs/platform/log/common/log'; +import type * as vscode from 'vscode'; suite('ExtHostDiagnostics', () => { @@ -96,7 +97,7 @@ suite('ExtHostDiagnostics', () => { assert.throws(() => array.pop()); assert.throws(() => array[0] = new Diagnostic(new Range(0, 0, 0, 0), 'evil')); - collection.forEach((uri, array: readonly Diagnostic[]) => { + collection.forEach((uri: URI, array: readonly vscode.Diagnostic[]): any => { assert.throws(() => (array as Diagnostic[]).length = 0); assert.throws(() => (array as Diagnostic[]).pop()); assert.throws(() => (array as Diagnostic[])[0] = new Diagnostic(new Range(0, 0, 0, 0), 'evil'));