<commit_before>const React = require("react");
const { DOM: dom, PropTypes, createFactory } = React;
const { connect } = require("react-redux");
const { bindActionCreators } = require("redux");
const actions = require("../actions");

require("./App.css");
require("../lib/themes/light-theme.css");

const Sources = createFactory(require("./Sources"));
const Editor = createFactory(require("./Editor"));
const SplitBox = createFactory(require("./SplitBox"));
const RightSidebar = createFactory(require("./RightSidebar"));
const SourceTabs = createFactory(require("./SourceTabs"));
const SourceFooter = createFactory(require("./SourceFooter"));
const Autocomplete = createFactory(require("./Autocomplete"));
const { getSelectedSource, getSources } = require("../selectors");
const { endTruncateStr } = require("../utils/utils");
const { KeyShortcuts } = require("../lib/devtools-sham/client/shared/key-shortcuts");
const { isHiddenSource, getURL } = require("../utils/sources-tree");

function searchResults(sources) {
  function getSourcePath(source) {
    const { path } = getURL(source);
    return endTruncateStr(path, 50);
  }

  return sources.valueSeq()
    .filter(source => !isHiddenSource(source))
    .map(source => ({
      value: getSourcePath(source),
      title: getSourcePath(source).split("/").pop(),
      subtitle: getSourcePath(source),
      id: source.get("id")
    }))
    .toJS();
}

const App = React.createClass({
  propTypes: {
    sources: PropTypes.object,
    selectedSource: PropTypes.object,
    selectSource: PropTypes.func
  },

  displayName: "App",

  getInitialState() {
    return {
      searchOn: false
    };
  },

  componentDidMount() {
    this.shortcuts = new KeyShortcuts({ window });
    this.shortcuts.on("Cmd+P", this.toggleSourcesSearch);
    window.addEventListener("keydown", this.onKeyDown);
  },

  componentWillUnmount() {
    this.shortcuts.off("Cmd+P", this.toggleSourcesSearch);
    window.removeEventListener("keydown", this.onKeyDown);
  },

  toggleSourcesSearch(key, e) {
    e.preventDefault();
    this.setState({ searchOn: !this.state.searchOn });
  },

  onKeyDown(e) {
    if (e.key === "Escape") {
      this.setState({ searchOn: false });
      e.preventDefault();
    }
  },

  renderSourcesSearch() {<commit_msg>Use `CmdOrCtrl` modifier identifier instead of just `Cmd` for the search shortcut<commit_after>const React = require("react");
const { DOM: dom, PropTypes, createFactory } = React;
const { connect } = require("react-redux");
const { bindActionCreators } = require("redux");
const actions = require("../actions");

require("./App.css");
require("../lib/themes/light-theme.css");

const Sources = createFactory(require("./Sources"));
const Editor = createFactory(require("./Editor"));
const SplitBox = createFactory(require("./SplitBox"));
const RightSidebar = createFactory(require("./RightSidebar"));
const SourceTabs = createFactory(require("./SourceTabs"));
const SourceFooter = createFactory(require("./SourceFooter"));
const Autocomplete = createFactory(require("./Autocomplete"));
const { getSelectedSource, getSources } = require("../selectors");
const { endTruncateStr } = require("../utils/utils");
const { KeyShortcuts } = require("../lib/devtools-sham/client/shared/key-shortcuts");
const { isHiddenSource, getURL } = require("../utils/sources-tree");

function searchResults(sources) {
  function getSourcePath(source) {
    const { path } = getURL(source);
    return endTruncateStr(path, 50);
  }

  return sources.valueSeq()
    .filter(source => !isHiddenSource(source))
    .map(source => ({
      value: getSourcePath(source),
      title: getSourcePath(source).split("/").pop(),
      subtitle: getSourcePath(source),
      id: source.get("id")
    }))
    .toJS();
}

const App = React.createClass({
  propTypes: {
    sources: PropTypes.object,
    selectedSource: PropTypes.object,
    selectSource: PropTypes.func
  },

  displayName: "App",

  getInitialState() {
    return {
      searchOn: false
    };
  },

  componentDidMount() {
    this.shortcuts = new KeyShortcuts({ window });
    this.shortcuts.on("CmdOrCtrl+P", this.toggleSourcesSearch);
    window.addEventListener("keydown", this.onKeyDown);
  },

  componentWillUnmount() {
    this.shortcuts.off("CmdOrCtrl+P", this.toggleSourcesSearch);
    window.removeEventListener("keydown", this.onKeyDown);
  },

  toggleSourcesSearch(key, e) {
    e.preventDefault();
    this.setState({ searchOn: !this.state.searchOn });
  },

  onKeyDown(e) {
    if (e.key === "Escape") {
      this.setState({ searchOn: false });
      e.preventDefault();
    }
  },

  renderSourcesSearch() {
{'fraction_non_alphanumeric': 0.16752799310938846, 'fraction_numerical': 0.0008613264427217916, 'mean_word_length': 4.278409090909091, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 7, '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': '2855934', 'n_tokens_mistral': 1416, 'n_tokens_neox': 1385, 'n_words': 259}