<commit_before>/**
 * Inspired by the Selection save and restore module for Rangy by <NAME>
 * Saves and restores ranges using invisible marker elements in the DOM.
 */
var rangeSaveRestore = (function() {
  var boundaryMarkerId = 0;

  // (U+FEFF) zero width no-break space
  var markerTextChar = '\ufeff';

  var getMarker = function(host, id) {
    return host.querySelector('#'+ id);
  };

  return {

    insertRangeBoundaryMarker: function(range, atStart) {
      var markerId = 'editable-range-boundary-' + (boundaryMarkerId += 1);
      var markerEl;
      var doc = window.document;

      // Clone the Range and collapse to the appropriate boundary point
      var boundaryRange = range.cloneRange();
      boundaryRange.collapse(atStart);

      // Create the marker element containing a single invisible character using DOM methods and insert it
      markerEl = doc.createElement('span');
      markerEl.id = markerId;
      markerEl.setAttribute('data-editable', 'remove');
      markerEl.style.lineHeight = '0';
      markerEl.style.display = 'none';
      // markerEl.className = "rangySelectionBoundary";
      markerEl.appendChild(doc.createTextNode(markerTextChar));

      boundaryRange.insertNode(markerEl);
      boundaryRange.detach();
      return markerEl;
    },

    setRangeBoundary: function(host, range, markerId, atStart) {
      var markerEl = getMarker(host, markerId);
      if (markerEl) {<commit_msg>Use the correct document in rangeSaveRestore<commit_after>/**
 * Inspired by the Selection save and restore module for Rangy by <NAME>
 * Saves and restores ranges using invisible marker elements in the DOM.
 */
var rangeSaveRestore = (function() {
  var boundaryMarkerId = 0;

  // (U+FEFF) zero width no-break space
  var markerTextChar = '\ufeff';

  var getMarker = function(host, id) {
    return host.querySelector('#'+ id);
  };

  return {

    insertRangeBoundaryMarker: function(range, atStart) {
      var markerId = 'editable-range-boundary-' + (boundaryMarkerId += 1);
      var markerEl;
      var container = range.commonAncestorContainer;

      // If ownerDocument is null the commonAncestorContainer is window.document
      if (container.ownerDocument == null) {
        error('Cannot save range: range is emtpy');
      }
      var doc = container.ownerDocument.defaultView.document;

      // Clone the Range and collapse to the appropriate boundary point
      var boundaryRange = range.cloneRange();
      boundaryRange.collapse(atStart);

      // Create the marker element containing a single invisible character using DOM methods and insert it
      markerEl = doc.createElement('span');
      markerEl.id = markerId;
      markerEl.setAttribute('data-editable', 'remove');
      markerEl.style.lineHeight = '0';
      markerEl.style.display = 'none';
      markerEl.appendChild(doc.createTextNode(markerTextChar));

      boundaryRange.insertNode(markerEl);
      boundaryRange.detach();
      return markerEl;
    },

    setRangeBoundary: function(host, range, markerId, atStart) {
      var markerEl = getMarker(host, markerId);
      if (markerEl) {
{'fraction_non_alphanumeric': 0.10269576379974327, 'fraction_numerical': 0.0019255455712451862, 'mean_word_length': 3.3291666666666666, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, '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': '1174874', 'n_tokens_mistral': 870, 'n_tokens_neox': 849, 'n_words': 255}