Sha256: 1b72f9ba64b003eca82aae7d567cccfdcc5c7deb3b91dd7fbbe78530242fb6a9

Contents?: true

Size: 1.24 KB

Versions: 8

Compression:

Stored size: 1.24 KB

Contents

CodeMirror.braceRangeFinder = function(cm, start) {
  var line = start.line, lineText = cm.getLine(line);
  var at = lineText.length, startChar, tokenType;
  for (;;) {
    var found = lineText.lastIndexOf("{", at);
    if (found < start.ch) break;
    tokenType = cm.getTokenAt(CodeMirror.Pos(line, found + 1)).type;
    if (!/^(comment|string)/.test(tokenType)) { startChar = found; break; }
    at = found - 1;
  }
  if (startChar == null || lineText.lastIndexOf("}") > startChar) return;
  var count = 1, lastLine = cm.lineCount(), end, endCh;
  outer: for (var i = line + 1; i < lastLine; ++i) {
    var text = cm.getLine(i), pos = 0;
    for (;;) {
      var nextOpen = text.indexOf("{", pos), nextClose = text.indexOf("}", pos);
      if (nextOpen < 0) nextOpen = text.length;
      if (nextClose < 0) nextClose = text.length;
      pos = Math.min(nextOpen, nextClose);
      if (pos == text.length) break;
      if (cm.getTokenAt(CodeMirror.Pos(i, pos + 1)).type == tokenType) {
        if (pos == nextOpen) ++count;
        else if (!--count) { end = i; endCh = pos; break outer; }
      }
      ++pos;
    }
  }
  if (end == null || end == line + 1) return;
  return {from: CodeMirror.Pos(line, startChar + 1),
          to: CodeMirror.Pos(end, endCh)};
};

Version data entries

8 entries across 8 versions & 1 rubygems

Version Path
glebtv-ckeditor-4.1.1.7 app/assets/javascripts/ckeditor/plugins/codemirror/js/addon/fold/brace-fold.js
glebtv-ckeditor-4.1.1.6 app/assets/javascripts/ckeditor/plugins/codemirror/js/addon/fold/brace-fold.js
glebtv-ckeditor-4.1.1.5 app/assets/javascripts/ckeditor/plugins/codemirror/js/addon/fold/brace-fold.js
glebtv-ckeditor-4.1.1.4 app/assets/javascripts/ckeditor/plugins/codemirror/js/addon/fold/brace-fold.js
glebtv-ckeditor-4.1.1.3 app/assets/javascripts/ckeditor/plugins/codemirror/js/addon/fold/brace-fold.js
glebtv-ckeditor-4.1.1.2 app/assets/javascripts/ckeditor/plugins/codemirror/js/addon/fold/brace-fold.js
glebtv-ckeditor-4.1.1.1 app/assets/javascripts/ckeditor/plugins/codemirror/js/addon/fold/brace-fold.js
glebtv-ckeditor-4.1.1 app/assets/javascripts/ckeditor/plugins/codemirror/js/addon/fold/brace-fold.js