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

Commit a3abbf1

Browse files
Łukasz SobekjasonLaster
authored andcommitted
Removes unused modifiers reference (#5781)
1 parent e450058 commit a3abbf1

4 files changed

Lines changed: 15 additions & 20 deletions

File tree

src/actions/file-search.js

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -133,12 +133,11 @@ export function traverseResults(rev: boolean, editor: Editor) {
133133

134134
export function closeFileSearch(editor: Editor) {
135135
return ({ getState, dispatch }: ThunkArgs) => {
136-
const modifiers = getFileSearchModifiers(getState());
137136
const query = getFileSearchQuery(getState());
138137

139-
if (editor && modifiers) {
138+
if (editor) {
140139
const ctx = { ed: editor, cm: editor.codeMirror };
141-
removeOverlay(ctx, query, modifiers.toJS());
140+
removeOverlay(ctx, query);
142141
}
143142

144143
dispatch(setFileSearchQuery(""));

src/components/Editor/SearchBar.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -129,10 +129,10 @@ class SearchBar extends Component<Props, State> {
129129
};
130130

131131
clearSearch = () => {
132-
const { editor: ed, query, modifiers } = this.props;
133-
if (ed && modifiers) {
132+
const { editor: ed, query } = this.props;
133+
if (ed) {
134134
const ctx = { ed, cm: ed.codeMirror };
135-
removeOverlay(ctx, query, modifiers.toJS());
135+
removeOverlay(ctx, query);
136136
}
137137
};
138138

src/utils/editor/source-search.js

Lines changed: 9 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ function SearchState() {
3131
* @memberof utils/source-search
3232
* @static
3333
*/
34-
function getSearchState(cm: any, query, modifiers) {
34+
function getSearchState(cm: any, query) {
3535
const state = cm.state.search || (cm.state.search = new SearchState());
3636
return state;
3737
}
@@ -141,11 +141,11 @@ function doSearch(ctx, rev, query, keepSelection, modifiers: SearchModifiers) {
141141

142142
return cm.operation(function() {
143143
if (!query || isWhitespace(query)) {
144-
clearSearch(cm, query, modifiers);
144+
clearSearch(cm, query);
145145
return;
146146
}
147147

148-
const state = getSearchState(cm, query, modifiers);
148+
const state = getSearchState(cm, query);
149149
const isNewQuery = state.query !== query;
150150
state.query = query;
151151

@@ -175,7 +175,7 @@ function searchNext(ctx, rev, query, newQuery, modifiers) {
175175
const { cm, ed } = ctx;
176176
let nextMatch;
177177
cm.operation(function() {
178-
const state = getSearchState(cm, query, modifiers);
178+
const state = getSearchState(cm, query);
179179
const pos = getCursorPos(newQuery, rev, state);
180180

181181
if (!state.query) {
@@ -214,12 +214,8 @@ function searchNext(ctx, rev, query, newQuery, modifiers) {
214214
* @memberof utils/source-search
215215
* @static
216216
*/
217-
export function removeOverlay(
218-
ctx: any,
219-
query: string,
220-
modifiers: SearchModifiers
221-
) {
222-
const state = getSearchState(ctx.cm, query, modifiers);
217+
export function removeOverlay(ctx: any, query: string) {
218+
const state = getSearchState(ctx.cm, query);
223219
ctx.cm.removeOverlay(state.overlay);
224220
const { line, ch } = ctx.cm.getCursor();
225221
ctx.cm.doc.setSelection({ line, ch }, { line, ch }, { scroll: false });
@@ -231,8 +227,8 @@ export function removeOverlay(
231227
* @memberof utils/source-search
232228
* @static
233229
*/
234-
function clearSearch(cm, query: string, modifiers: SearchModifiers) {
235-
const state = getSearchState(cm, query, modifiers);
230+
function clearSearch(cm, query: string) {
231+
const state = getSearchState(cm, query);
236232

237233
state.results = [];
238234

@@ -255,7 +251,7 @@ export function find(
255251
keepSelection: boolean,
256252
modifiers: SearchModifiers
257253
) {
258-
clearSearch(ctx.cm, query, modifiers);
254+
clearSearch(ctx.cm, query);
259255
return doSearch(ctx, false, query, keepSelection, modifiers);
260256
}
261257

src/utils/editor/tests/source-search.spec.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -127,7 +127,7 @@ describe("source-search", () => {
127127
}
128128
}
129129
};
130-
removeOverlay(ctx, "test", modifiers);
130+
removeOverlay(ctx, "test");
131131
expect(ctx.cm.removeOverlay).toHaveBeenCalled();
132132
expect(ctx.cm.getCursor).toHaveBeenCalled();
133133
expect(ctx.cm.doc.setSelection).toHaveBeenCalledWith(

0 commit comments

Comments
 (0)