1
0

indent-fold.js 570 B

1234567891011
  1. CodeMirror.indentRangeFinder = function(cm, start) {
  2. var tabSize = cm.getOption("tabSize"), firstLine = cm.getLine(start.line);
  3. var myIndent = CodeMirror.countColumn(firstLine, null, tabSize);
  4. for (var i = start.line + 1, end = cm.lineCount(); i < end; ++i) {
  5. var curLine = cm.getLine(i);
  6. if (CodeMirror.countColumn(curLine, null, tabSize) < myIndent &&
  7. CodeMirror.countColumn(cm.getLine(i-1), null, tabSize) > myIndent)
  8. return {from: CodeMirror.Pos(start.line, firstLine.length),
  9. to: CodeMirror.Pos(i, curLine.length)};
  10. }
  11. };