<commit_before>// Replace works a little oddly -- it will do the replace on the next
// Ctrl-G (or whatever is bound to findNext) press. You prevent a
// replace by making sure the match is no longer selected when hitting
// Ctrl-G.

(function() {

  var wrap;
  function dialogDiv(cm, template) {
    wrap = cm.getWrapperElement();
    wrap.style.bottom = '40px'; // offset search dialog height
    var dialog;
    dialog = document.getElementById('code').appendChild(document.createElement('div'));
    dialog.className = 'search-dialog pin-bottom col12 clearfix';
    dialog.innerHTML = template;
    return dialog;
  }

  function close() {
    if (wrap) wrap.style.bottom = 0;
    $('.search-dialog').remove();
  }

  function newDialog(cm, template, callback) {
    var dialog = dialogDiv(cm, template),
        me = cm,
        inp = dialog.getElementsByTagName('input')[0],
        selection = cm.getSelection();
    if (selection) inp.value = selection;
    if (inp) {
      CodeMirror.connect(inp, 'keydown', function(e) {
        if (e.keyCode == 13) {
          CodeMirror.e_stop(e);
          clearSearch(me);
          me.focus();
          callback(inp.value);
        } else if (e.keyCode == 27) {
          CodeMirror.e_stop(e);
          close();
          me.focus();
        }
      });
      inp.focus();
    }
    dialog.querySelector('.icon.x').addEventListener('click', function() {
      clearSearch(me);
      me.focus();
      close();
    });
    dialog.querySelector('.icon.help').addEventListener('click', function() {
      this.parentNode.removeChild(this);
      wrap.style.bottom = '115px';
      dialog.querySelector('.search-help').classList.remove('hidden');
      return false;
    });
    window.addEventListener('keydown', function(e) {
      if (e.which == 27) {
        clearSearch(cm);
        close();
      }
    });

    return close;
  };

  var helpText = '<div class="clearfix keyline-top small fill-darken0 search-help hidden">'+
    '<div class="pad1">Use /re/ syntax for regex search</div>'+<commit_msg>fix search help offset<commit_after>// Replace works a little oddly -- it will do the replace on the next
// Ctrl-G (or whatever is bound to findNext) press. You prevent a
// replace by making sure the match is no longer selected when hitting
// Ctrl-G.

(function() {

  var wrap;
  function dialogDiv(cm, template) {
    wrap = cm.getWrapperElement();
    wrap.style.bottom = '40px'; // offset search dialog height
    var dialog;
    dialog = document.getElementById('code').appendChild(document.createElement('div'));
    dialog.className = 'search-dialog pin-bottom col12 clearfix';
    dialog.innerHTML = template;
    return dialog;
  }

  function close() {
    if (wrap) wrap.style.bottom = 0;
    $('.search-dialog').remove();
  }

  function newDialog(cm, template, callback) {
    var dialog = dialogDiv(cm, template),
        me = cm,
        inp = dialog.getElementsByTagName('input')[0],
        selection = cm.getSelection();
    if (selection) inp.value = selection;
    if (inp) {
      CodeMirror.connect(inp, 'keydown', function(e) {
        if (e.keyCode == 13) {
          CodeMirror.e_stop(e);
          clearSearch(me);
          me.focus();
          callback(inp.value);
        } else if (e.keyCode == 27) {
          CodeMirror.e_stop(e);
          close();
          me.focus();
        }
      });
      inp.focus();
    }
    dialog.querySelector('.icon.x').addEventListener('click', function() {
      clearSearch(me);
      me.focus();
      close();
    });
    dialog.querySelector('.icon.help').addEventListener('click', function() {
      this.parentNode.removeChild(this);
      wrap.style.bottom = '163px';
      dialog.querySelector('.search-help').classList.remove('hidden');
      return false;
    });
    window.addEventListener('keydown', function(e) {
      if (e.which == 27) {
        clearSearch(cm);
        close();
      }
    });

    return close;
  };

  var helpText = '<div class="clearfix keyline-top small fill-darken0 search-help hidden">'+
    '<div class="pad1">Use /re/ syntax for regex search</div>'+
{'fraction_non_alphanumeric': 0.14809419762078174, 'fraction_numerical': 0.008254430687059966, 'mean_word_length': 2.5888501742160277, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 9, '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': '2192473', 'n_tokens_mistral': 1240, 'n_tokens_neox': 1205, 'n_words': 298}