Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- diff --git a/public/js/components/EditorSearchBar.js b/public/js/components/EditorSearchBar.js
- index cecba60..cbb740e 100644
- --- a/public/js/components/EditorSearchBar.js
- +++ b/public/js/components/EditorSearchBar.js
- @@ -5,6 +5,7 @@ const Svg = require("./utils/Svg");
- const { isEnabled } = require("devtools-config");
- const { find, findNext, findPrev } = require("../utils/source-search");
- const classnames = require("classnames");
- +const debounce = require("lodash.debounce");
- require("./EditorSearchBar.css");
- @@ -92,25 +93,37 @@ const EditorSearchBar = React.createClass({
- },
- onKeyUp(e) {
- - const ed = this.props.editor;
- - const ctx = { ed, cm: ed.codeMirror };
- - const { query, index, count } = this.state;
- -
- if (e.key != "Enter") {
- return;
- }
- if (e.shiftKey) {
- - findPrev(ctx, query);
- - const nextIndex = index == 0 ? count - 1 : index - 1;
- - this.setState({ index: nextIndex });
- + this.searchNext();
- } else {
- - findNext(ctx, query);
- - const nextIndex = index == count - 1 ? 0 : index + 1;
- - this.setState({ index: nextIndex });
- + this.searchPrev();
- }
- },
- + searchNext: debounce(function() {
- + const ed = this.props.editor;
- + const ctx = { ed, cm: ed.codeMirror };
- + const { query, index, count } = this.state;
- +
- + findNext(ctx, query);
- + const nextIndex = index == count - 1 ? 0 : index + 1;
- + this.setState({ index: nextIndex });
- + }),
- +
- + searchPrev: debounce(function() {
- + const ed = this.props.editor;
- + const ctx = { ed, cm: ed.codeMirror };
- + const { query, index, count } = this.state;
- +
- + findPrev(ctx, query);
- + const nextIndex = index == 0 ? count - 1 : index - 1;
- + this.setState({ index: nextIndex });
- + }),
- +
- renderSummary() {
- const { count, index, query } = this.state;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement