<commit_before>const React = require("react");
const { DOM: dom, PropTypes } = React;
const { findDOMNode } = require("react-dom");
const Svg = require("./utils/Svg");
const { isEnabled } = require("../feature");
const { find, findNext, findPrev } = require("../utils/source-search");
const classnames = require("classnames");

require("./EditorSearchBar.css");

function countMatches(query, text) {
  const re = new RegExp(query, "g");
  const match = text.match(re);
  return match ? match.length : 0;
}

const EditorSearchBar = React.createClass({

  propTypes: {
    editor: PropTypes.object,
    sourceText: PropTypes.object
  },

  displayName: "EditorSearchBar",

  getInitialState() {
    return {
      enabled: false,
      query: "",
      count: 0,
      index: 0
    };
  },

  contextTypes: {
    shortcuts: PropTypes.object
  },

  componentWillUnmount() {
    const shortcuts = this.context.shortcuts;
    if (isEnabled("search")) {
      shortcuts.off("Cmd+f", this.toggleSearch);
      shortcuts.off("Escape", this.onEscape);
    }
  },

  componentDidMount() {
    const shortcuts = this.context.shortcuts;
    if (isEnabled("search")) {
      shortcuts.on("Cmd+f", this.toggleSearch);
      shortcuts.on("Escape", this.onEscape);
    }
  },

  componentDidUpdate() {
    if (this.searchInput()) {
      this.searchInput().focus();
    }
  },

  onEscape(shortcut, e) {
    if (this.state.enabled) {
      this.setState({ enabled: false });
      e.preventDefault();
    }
  },

  toggleSearch(shortcut, e) {
    e.stopPropagation();
    e.preventDefault();

    this.setState({ enabled: !this.state.enabled });
<commit_msg>Fix the key shortcut in code search to be compatible with linux/windows.<commit_after>const React = require("react");
const { DOM: dom, PropTypes } = React;
const { findDOMNode } = require("react-dom");
const Svg = require("./utils/Svg");
const { isEnabled } = require("../feature");
const { find, findNext, findPrev } = require("../utils/source-search");
const classnames = require("classnames");

require("./EditorSearchBar.css");

function countMatches(query, text) {
  const re = new RegExp(query, "g");
  const match = text.match(re);
  return match ? match.length : 0;
}

const EditorSearchBar = React.createClass({

  propTypes: {
    editor: PropTypes.object,
    sourceText: PropTypes.object
  },

  displayName: "EditorSearchBar",

  getInitialState() {
    return {
      enabled: false,
      query: "",
      count: 0,
      index: 0
    };
  },

  contextTypes: {
    shortcuts: PropTypes.object
  },

  componentWillUnmount() {
    const shortcuts = this.context.shortcuts;
    if (isEnabled("search")) {
      shortcuts.off("CmdOrCtrl+F", this.toggleSearch);
      shortcuts.off("Escape", this.onEscape);
    }
  },

  componentDidMount() {
    const shortcuts = this.context.shortcuts;
    if (isEnabled("search")) {
      shortcuts.on("CmdOrCtrl+F", this.toggleSearch);
      shortcuts.on("Escape", this.onEscape);
    }
  },

  componentDidUpdate() {
    if (this.searchInput()) {
      this.searchInput().focus();
    }
  },

  onEscape(shortcut, e) {
    if (this.state.enabled) {
      this.setState({ enabled: false });
      e.preventDefault();
    }
  },

  toggleSearch(shortcut, e) {
    e.stopPropagation();
    e.preventDefault();

    this.setState({ enabled: !this.state.enabled });

{'fraction_non_alphanumeric': 0.15907059874888294, 'fraction_numerical': 0.0017873100983020554, 'mean_word_length': 3.250632911392405, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '354162', 'n_tokens_mistral': 1096, 'n_tokens_neox': 1067, 'n_words': 215}