Thanks to visit codestin.com
Credit goes to github.com

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

Commit f7dc587

Browse files
committed
fix flow and lint errors
1 parent dfaa0c1 commit f7dc587

File tree

2 files changed

+6
-15
lines changed

2 files changed

+6
-15
lines changed

‎src/actions/tests/ui.spec.js‎

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,10 @@ import { createStore, selectors, actions } from "../../utils/test-head";
22

33
const {
44
getActiveSearch,
5-
getFileSearchQueryState,
6-
getFileSearchModifierState,
75
getFrameworkGroupingState,
86
getPaneCollapse,
97
getSymbolSearchType,
10-
getHighlightedLineRange,
11-
getSearchResults
8+
getHighlightedLineRange
129
} = selectors;
1310

1411
describe("ui", () => {

‎src/components/Editor/SearchBar.js‎

Lines changed: 5 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,7 @@ function getShortcuts() {
4545
}
4646

4747
type SearchBarState = {
48+
query: string,
4849
selectedResultIndex: number,
4950
count: number,
5051
index: number
@@ -97,8 +98,10 @@ class SearchBar extends Component {
9798
}
9899

99100
componentDidMount() {
100-
const shortcuts = this.context.shortcuts;
101+
// overwrite this.doSearch with debounced version to
102+
// reduce frequency of queries
101103
this.doSearch = debounce(this.doSearch, 100);
104+
const shortcuts = this.context.shortcuts;
102105
const {
103106
searchShortcut,
104107
searchAgainShortcut,
@@ -161,23 +164,14 @@ class SearchBar extends Component {
161164

162165
if (this.props.searchOn && editor) {
163166
const selection = editor.codeMirror.getSelection();
164-
this.setSearchValue(selection);
167+
this.setState({ query: selection });
165168
if (selection !== "") {
166169
this.doSearch(selection);
167170
}
168171
this.selectSearchInput();
169172
}
170173
};
171174

172-
setSearchValue = (value: string) => {
173-
const searchInput = this.searchInput();
174-
if (value == "" || !searchInput) {
175-
return;
176-
}
177-
178-
searchInput.value = value;
179-
};
180-
181175
selectSearchInput = () => {
182176
const searchInput = this.searchInput();
183177
if (searchInput) {

0 commit comments

Comments
 (0)