<commit_before>(function(mod) {
  if (typeof exports == "object" && typeof module == "object") // CommonJS
    mod(require("../../lib/codemirror"));
  else if (typeof define == "function" && define.amd) // AMD
    define(["../../lib/codemirror"], mod);
  else // Plain browser env
    mod(CodeMirror);
})(function(CodeMirror) {
  "use strict";
  var WRAP_CLASS = "CodeMirror-selectiveline";
  var BACK_CLASS = "CodeMirror-selectiveline-background";
  var GUTT_CLASS = "CodeMirror-selectiveline-gutter";

  CodeMirror.defineOption("styleSelectiveLine", false, function(cm, val, old) {
    var prev = old == CodeMirror.Init ? false : old;
    if (val == prev) return
    if (prev) {
      cm.off("beforeSelectionChange", selectionChange);
      clearSelectiveLines(cm);
      delete cm.state.selectiveLines;
    }
    if (val) {
      cm.state.selectiveLines = [];
      updateSelectiveLines(cm, cm.listSelections());
      cm.on("beforeSelectionChange", selectionChange);
    }
  });

  function clearSelectiveLines(cm) {
    for (var i = 0; i < cm.state.selectiveLines.length; i++) {
      cm.removeLineClass(cm.state.selectiveLines[i], "wrap", WRAP_CLASS);
      cm.removeLineClass(cm.state.selectiveLines[i], "background", BACK_CLASS);
      cm.removeLineClass(cm.state.selectiveLines[i], "gutter", GUTT_CLASS);
    }
  }

  function sameArray(a, b) {
    if (a.length != b.length) return false;
    for (var i = 0; i < a.length; i++)
      if (a[i] != b[i]) return false;
    return true;
  }

  function updateSelectiveLines(cm, ranges) {
    var active = [];
    var range = ranges[0];
    var lineCount = Math.abs(range.anchor.line - range.head.line);
    var startLine = Math.min(range.anchor.line, range.head.line);
    for (var i = 0; i < lineCount; i++) {
      var line = cm.getLineHandleVisualStart(startLine + i);
      if (active[active.length - 1] != line) active.push(line);
    }
    if (sameArray(cm.state.selectiveLines, active)) return;
    cm.operation(function() {
      clearSelectiveLines(cm);
      for (var i = 0; i < active.length; i++) {
        cm.addLineClass(active[i], "wrap", WRAP_CLASS);
        cm.addLineClass(active[i], "background", BACK_CLASS);
        cm.addLineClass(active[i], "gutter", GUTT_CLASS);
      }
      cm.state.selectiveLines = active;
    });<commit_msg>selective-line 오류 수정<commit_after>(function(mod) {
  if (typeof exports == "object" && typeof module == "object") // CommonJS
    mod(require("../../lib/codemirror"));
  else if (typeof define == "function" && define.amd) // AMD
    define(["../../lib/codemirror"], mod);
  else // Plain browser env
    mod(CodeMirror);
})(function(CodeMirror) {
  "use strict";
  var WRAP_CLASS = "CodeMirror-selectiveline";
  var BACK_CLASS = "CodeMirror-selectiveline-background";
  var GUTT_CLASS = "CodeMirror-selectiveline-gutter";

  CodeMirror.defineOption("styleSelectiveLine", false, function(cm, val, old) {
    var prev = old == CodeMirror.Init ? false : old;
    if (val == prev) return
    if (prev) {
      cm.off("beforeSelectionChange", selectionChange);
      clearSelectiveLines(cm);
      delete cm.state.selectiveLines;
    }
    if (val) {
      cm.state.selectiveLines = [];
      updateSelectiveLines(cm, cm.listSelections());
      cm.on("beforeSelectionChange", selectionChange);
    }
  });

  function clearSelectiveLines(cm) {
    for (var i = 0; i < cm.state.selectiveLines.length; i++) {
      cm.removeLineClass(cm.state.selectiveLines[i], "wrap", WRAP_CLASS);
      cm.removeLineClass(cm.state.selectiveLines[i], "background", BACK_CLASS);
      cm.removeLineClass(cm.state.selectiveLines[i], "gutter", GUTT_CLASS);
    }
  }

  function sameArray(a, b) {
    if (a.length != b.length) return false;
    for (var i = 0; i < a.length; i++)
      if (a[i] != b[i]) return false;
    return true;
  }

  function updateSelectiveLines(cm, ranges) {
    var active = [];
    var range = ranges[0];
    var lineCount = Math.abs(range.anchor.line - range.head.line);
    var startLine = Math.min(range.anchor.line, range.head.line);
    var endRange = (range.anchor.line > range.head.line) ? range.anchor : range.head;

    if(endRange.ch > 0) {
      lineCount++;
    }

    for (var i = 0; i < lineCount; i++) {
      var line = cm.getLineHandleVisualStart(startLine + i);
      if (active[active.length - 1] != line) active.push(line);
    }
    if (sameArray(cm.state.selectiveLines, active)) return;
    cm.operation(function() {
      clearSelectiveLines(cm);
      for (var i = 0; i < active.length; i++) {
        cm.addLineClass(active[i], "wrap", WRAP_CLASS);
        cm.addLineClass(active[i], "background", BACK_CLASS);
        cm.addLineClass(active[i], "gutter", GUTT_CLASS);
      }
      cm.state.selectiveLines = active;
    });
{'fraction_non_alphanumeric': 0.15848026868178003, 'fraction_numerical': 0.00272879932829555, 'mean_word_length': 3.243098842386465, 'pattern_counts': {'":': 0, '<': 11, '<?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': '1772778', 'n_tokens_mistral': 1619, 'n_tokens_neox': 1557, 'n_words': 333}