Skip to content
This repository was archived by the owner on Jan 11, 2023. It is now read-only.

Commit 197f9f0

Browse files
authored
Disable match index (#3008)
1 parent 272fbae commit 197f9f0

File tree

1 file changed

+6
-25
lines changed

1 file changed

+6
-25
lines changed

src/utils/editor/source-search.js

Lines changed: 6 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
// @flow
22

33
import buildQuery from "./build-query";
4-
import findIndex from "lodash/findIndex";
54

65
import type { SearchModifiers } from "../../types";
76

@@ -31,17 +30,6 @@ function SearchState() {
3130
*/
3231
function getSearchState(cm: any, query, modifiers) {
3332
let state = cm.state.search || (cm.state.search = new SearchState());
34-
35-
// avoid generating a cursor and iterating over the results for an empty query
36-
if (query) {
37-
let cursor = getSearchCursor(cm, query, null, modifiers);
38-
39-
state.results = [];
40-
while (cursor.findNext()) {
41-
state.results.push(cursor.pos);
42-
}
43-
}
44-
4533
return state;
4634
}
4735

@@ -151,7 +139,8 @@ function getMatchIndex(count: number, currentIndex: number, rev: boolean) {
151139
*/
152140
function doSearch(ctx, rev, query, keepSelection, modifiers: SearchModifiers) {
153141
let { cm } = ctx;
154-
let matchIndex = 0;
142+
const matchIndex = -1;
143+
155144
cm.operation(function() {
156145
if (!query || isWhitespace(query)) {
157146
return;
@@ -163,19 +152,11 @@ function doSearch(ctx, rev, query, keepSelection, modifiers: SearchModifiers) {
163152

164153
updateOverlay(cm, state, query, modifiers);
165154
updateCursor(cm, state, keepSelection);
155+
searchNext(ctx, rev, query, newQuery, modifiers);
166156

167-
const nextMatch = searchNext(ctx, rev, query, newQuery, modifiers);
168-
if (nextMatch) {
169-
if (state.matchIndex === -1) {
170-
matchIndex = findIndex(state.results, nextMatch);
171-
} else {
172-
const count = state.results.length;
173-
const currentIndex = state.matchIndex;
174-
matchIndex = getMatchIndex(count, currentIndex, rev);
175-
}
176-
177-
state.matchIndex = matchIndex;
178-
}
157+
// NOTE: We would like to find the correct match index based on where the
158+
// match is in the document.
159+
state.matchIndex = matchIndex;
179160
});
180161

181162
return matchIndex;

0 commit comments

Comments
 (0)