Fix NPE when search returns no results

This commit is contained in:
Rob Lourens
2018-05-14 17:02:35 -07:00
parent fc77396089
commit 0d376d890c

View File

@@ -188,7 +188,9 @@ class TextSearchResultsCollector {
}
private pushToCollector(): void {
const size = this._currentFileMatch.lineMatches.reduce((acc, match) => acc + match.offsetAndLengths.length, 0);
const size = this._currentFileMatch ?
this._currentFileMatch.lineMatches.reduce((acc, match) => acc + match.offsetAndLengths.length, 0) :
0;
this._batchedCollector.addItem(this._currentFileMatch, size);
}