Skip to content
This repository was archived by the owner on Sep 6, 2021. It is now read-only.

Commit 6ad6834

Browse files
committed
Merge pull request #9385 from jacksonweekes/iss8557
Issue #8557 ("Over 100000 matches" when there are exactly 100000 matches)
2 parents 7b45d82 + 0c83a92 commit 6ad6834

3 files changed

Lines changed: 23 additions & 7 deletions

File tree

src/search/FindInFiles.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -127,7 +127,9 @@ define(function (require, exports, module) {
127127

128128
// We have the max hits in just this 1 file. Stop searching this file.
129129
// This fixed issue #1829 where code hangs on too many hits.
130-
if (matches.length >= SearchModel.MAX_TOTAL_RESULTS) {
130+
// Adds one over MAX_TOTAL_RESULTS in order to know if the search has exceeded
131+
// or is equal to MAX_TOTAL_RESULTS. Additional result removed in SearchModel
132+
if (matches.length > SearchModel.MAX_TOTAL_RESULTS) {
131133
queryExpr.lastIndex = 0;
132134
break;
133135
}

src/search/SearchModel.js

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,13 @@ define(function (require, exports, module) {
9999
* @type {boolean}
100100
*/
101101
SearchModel.prototype.foundMaximum = false;
102-
102+
103+
/**
104+
* Whether or not we exceeded the maximum number of results in the search we did.
105+
* @type {boolean}
106+
*/
107+
SearchModel.prototype.exceedsMaximum = false;
108+
103109
/**
104110
* Clears out the model to an empty state.
105111
*/
@@ -112,6 +118,7 @@ define(function (require, exports, module) {
112118
this.scope = null;
113119
this.numMatches = 0;
114120
this.foundMaximum = false;
121+
this.exceedsMaximum = false;
115122
this.fireChanged();
116123
};
117124

@@ -157,6 +164,13 @@ define(function (require, exports, module) {
157164
this.numMatches += resultInfo.matches.length;
158165
if (this.numMatches >= SearchModel.MAX_TOTAL_RESULTS) {
159166
this.foundMaximum = true;
167+
168+
// Remove final result if there have been over MAX_TOTAL_RESULTS found
169+
if (this.numMatches > SearchModel.MAX_TOTAL_RESULTS) {
170+
this.results[fullpath].matches.pop();
171+
this.numMatches--;
172+
this.exceedsMaximum = true;
173+
}
160174
}
161175
};
162176

src/search/SearchResultsView.js

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@
2828
*/
2929
define(function (require, exports, module) {
3030
"use strict";
31-
31+
3232
var CommandManager = require("command/CommandManager"),
3333
Commands = require("command/Commands"),
3434
DocumentManager = require("document/DocumentManager"),
@@ -41,12 +41,12 @@ define(function (require, exports, module) {
4141
StringUtils = require("utils/StringUtils"),
4242
Strings = require("strings"),
4343
_ = require("thirdparty/lodash"),
44-
44+
4545
searchPanelTemplate = require("text!htmlContent/search-panel.html"),
4646
searchResultsTemplate = require("text!htmlContent/search-results.html"),
4747
searchSummaryTemplate = require("text!htmlContent/search-summary.html");
48-
49-
48+
49+
5050
/**
5151
* @const
5252
* The maximum results to show per page.
@@ -348,7 +348,7 @@ define(function (require, exports, module) {
348348
// This text contains some formatting, so all the strings are assumed to be already escaped
349349
summary = StringUtils.format(
350350
Strings.FIND_TITLE_SUMMARY,
351-
this._model.foundMaximum ? Strings.FIND_IN_FILES_MORE_THAN : "",
351+
this._model.exceedsMaximum ? Strings.FIND_IN_FILES_MORE_THAN : "",
352352
String(count.matches),
353353
(count.matches > 1) ? Strings.FIND_IN_FILES_MATCHES : Strings.FIND_IN_FILES_MATCH,
354354
filesStr

0 commit comments

Comments
 (0)