diff --git a/src/vs/workbench/services/search/node/textSearch.ts b/src/vs/workbench/services/search/node/textSearch.ts index 79640671f6aed6711d0118df0d3cabd7a0a4eb0d..276d7a468595593784a0f3c252181be934757403 100644 --- a/src/vs/workbench/services/search/node/textSearch.ts +++ b/src/vs/workbench/services/search/node/textSearch.ts @@ -22,6 +22,9 @@ interface ReadLinesOptions { } export class Engine implements ISearchEngine { + + private static PROGRESS_FLUSH_CHUNK_SIZE = 50; // optimization: number of files to process before emitting progress event + private rootFolders: string[]; private extraFiles: string[]; private maxResults: number; @@ -62,7 +65,9 @@ export class Engine implements ISearchEngine { // Emit progress() unless we got canceled or hit the limit if (processed && !this.isDone && !this.isCanceled && !this.limitReached) { - onProgress({ total: this.total, worked: this.worked }); + if (this.worked % Engine.PROGRESS_FLUSH_CHUNK_SIZE === 0) { + onProgress({ total: this.total, worked: this.worked }); + } } // Emit done() @@ -82,7 +87,9 @@ export class Engine implements ISearchEngine { } // Indicate progress to the outside - onProgress({ total: this.total, worked: this.worked }); + if (this.worked % Engine.PROGRESS_FLUSH_CHUNK_SIZE === 0) { + onProgress({ total: this.total, worked: this.worked }); + } let fileMatch: FileMatch = null;