Vergleich admin/jscripts/codemirror/addon/fold/indent-fold.js - 1.8.11 - 1.8.38

  Keine Änderungen   Hinzugefügt   Modifiziert   Entfernt
Zeile 10Zeile 10
    mod(CodeMirror);
})(function(CodeMirror) {
"use strict";

    mod(CodeMirror);
})(function(CodeMirror) {
"use strict";

 

function lineIndent(cm, lineNo) {
var text = cm.getLine(lineNo)
var spaceTo = text.search(/\S/)
if (spaceTo == -1 || /\bcomment\b/.test(cm.getTokenTypeAt(CodeMirror.Pos(lineNo, spaceTo + 1))))
return -1
return CodeMirror.countColumn(text, null, cm.getOption("tabSize"))
}


CodeMirror.registerHelper("fold", "indent", function(cm, start) {


CodeMirror.registerHelper("fold", "indent", function(cm, start) {

  var tabSize = cm.getOption("tabSize"), firstLine = cm.getLine(start.line);
if (!/\S/.test(firstLine)) return;
var getIndent = function(line) {
return CodeMirror.countColumn(line, null, tabSize);
};
var myIndent = getIndent(firstLine);
var lastLineInFold = null;

  var myIndent = lineIndent(cm, start.line)
if (myIndent < 0) return
var lastLineInFold = null





  // Go through lines until we find a line that definitely doesn't belong in
// the block we're folding, or to the end.
for (var i = start.line + 1, end = cm.lastLine(); i <= end; ++i) {

  // Go through lines until we find a line that definitely doesn't belong in
// the block we're folding, or to the end.
for (var i = start.line + 1, end = cm.lastLine(); i <= end; ++i) {

    var curLine = cm.getLine(i);
var curIndent = getIndent(curLine);
if (curIndent > myIndent) {

    var indent = lineIndent(cm, i)
if (indent == -1) {
} else if (indent > myIndent) {

      // Lines with a greater indent are considered part of the block.
lastLineInFold = i;

      // Lines with a greater indent are considered part of the block.
lastLineInFold = i;

    } else if (!/\S/.test(curLine)) {
// Empty lines might be breaks within the block we're trying to fold.

 
    } else {

    } else {

      // A non-empty line at an indent equal to or less than ours marks the
// start of another block.


      // If this line has non-space, non-comment content, and is
// indented less or equal to the start line, it is the start of
// another block.

      break;
}
}
if (lastLineInFold) return {

      break;
}
}
if (lastLineInFold) return {

    from: CodeMirror.Pos(start.line, firstLine.length),

    from: CodeMirror.Pos(start.line, cm.getLine(start.line).length),

    to: CodeMirror.Pos(lastLineInFold, cm.getLine(lastLineInFold).length)
};
});

    to: CodeMirror.Pos(lastLineInFold, cm.getLine(lastLineInFold).length)
};
});