<commit_before>TD.factory('EditSession', function() {
  return ace.require("ace/edit_session").EditSession;
});


// TODO(vojta): lazy load handlers
TD.factory('VimHandler', function() {
  return ace.require("ace/keyboard/vim").handler;
});

TD.factory('EmacsHandler', function() {
  return ace.require("ace/keyboard/emacs").handler;
});


TD.factory('ace', function() {
  return ace.edit('editor');
});


TD.factory('AceRange', function() {
  return ace.require('ace/range').Range;
});


TD.factory('HiddingFolding', function(AceRange) {
  return function(regexp) {
    var cache = [];

    this.getFoldWidget = function(session, foldStyle, row) {
      var previousMatch = cache[row - 1];
      var line = session.getLine(row);
      var currentMatch = cache[row] = regexp.test(line);

      if (row === 0) {
        return currentMatch ? '' : 'start';
      } else {
        if (!previousMatch) {
          return '';
        } else {
          return currentMatch ? '' : 'start';
        }
      }
    };

    this.getFoldWidgetRange = function(session, foldStyle, row) {
      var start = {row: row, column: 0};
      var end = {};

      while (!cache[row]) {
        if (typeof cache[row] === 'undefined') {
          if (row >= session.getLength()) break;
          this.getFoldWidget(session, foldStyle, row);
          if (cache[row]) break;
        }
        row++;
      }

      end.row = row - 1;
      end.column = session.getLine(end.row).length;

      return AceRange.fromPoints(start, end);
    };
  };
});


TD.factory('editor', function(EditSession, HiddingFolding, settings, ace) {

  // default configs
  ace.setShowPrintMargin(false);

  var updateSoftWrapSettings = function(wrap, session) {
    switch (wrap) {
      case -1:
        session.setUseWrapMode(false);
        break;
      case 0:
        session.setUseWrapMode(true);
        session.setWrapLimitRange(null, null);
        break;
      default:
        session.setUseWrapMode(true);
        session.setWrapLimitRange(wrap, wrap);
    }<commit_msg>Show ruler only if 80/100 wrapping<commit_after>TD.factory('EditSession', function() {
  return ace.require("ace/edit_session").EditSession;
});


// TODO(vojta): lazy load handlers
TD.factory('VimHandler', function() {
  return ace.require("ace/keyboard/vim").handler;
});

TD.factory('EmacsHandler', function() {
  return ace.require("ace/keyboard/emacs").handler;
});


TD.factory('ace', function() {
  return ace.edit('editor');
});


TD.factory('AceRange', function() {
  return ace.require('ace/range').Range;
});


TD.factory('HiddingFolding', function(AceRange) {
  return function(regexp) {
    var cache = [];

    this.getFoldWidget = function(session, foldStyle, row) {
      var previousMatch = cache[row - 1];
      var line = session.getLine(row);
      var currentMatch = cache[row] = regexp.test(line);

      if (row === 0) {
        return currentMatch ? '' : 'start';
      } else {
        if (!previousMatch) {
          return '';
        } else {
          return currentMatch ? '' : 'start';
        }
      }
    };

    this.getFoldWidgetRange = function(session, foldStyle, row) {
      var start = {row: row, column: 0};
      var end = {};

      while (!cache[row]) {
        if (typeof cache[row] === 'undefined') {
          if (row >= session.getLength()) break;
          this.getFoldWidget(session, foldStyle, row);
          if (cache[row]) break;
        }
        row++;
      }

      end.row = row - 1;
      end.column = session.getLine(end.row).length;

      return AceRange.fromPoints(start, end);
    };
  };
});


TD.factory('editor', function(EditSession, HiddingFolding, settings, ace) {

  var updateSoftWrapSettings = function(wrap, session) {
    switch (wrap) {
      case -1:
        session.setUseWrapMode(false);
        ace.setShowPrintMargin(false);
        break;
      case 0:
        session.setUseWrapMode(true);
        session.setWrapLimitRange(null, null);
        ace.setShowPrintMargin(false);
        break;
      default:
        session.setUseWrapMode(true);
        session.setWrapLimitRange(wrap, wrap);
        ace.setPrintMarginColumn(wrap);
        ace.setShowPrintMargin(true);
    }
{'fraction_non_alphanumeric': 0.15228789323164918, 'fraction_numerical': 0.004051477597712107, 'mean_word_length': 2.6527415143603132, 'pattern_counts': {'":': 0, '<': 3, '<?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': '1971137', 'n_tokens_mistral': 1326, 'n_tokens_neox': 1284, 'n_words': 254}