PluginProbe ʕ •ᴥ•ʔ
SiteOrigin CSS / 1.2.12
SiteOrigin CSS v1.2.12
1.2.1 1.2.10 1.2.11 1.2.12 1.2.13 1.2.14 1.2.2 1.2.3 1.2.4 1.2.5 1.2.6 1.2.7 1.2.8 1.2.9 1.3.0 1.3.1 1.3.2 1.4.0 1.4.1 1.4.2 1.4.3 1.5.0 1.5.1 1.5.10 1.5.11 1.5.2 1.5.3 1.5.4 1.5.5 1.5.6 1.5.7 1.5.8 1.5.9 1.6.0 1.6.1 1.6.2 1.6.3 1.6.4 1.6.5 1.6.6 trunk 1.0 1.0.1 1.0.2 1.0.3 1.0.4 1.0.5 1.0.6 1.0.7 1.0.8 1.1 1.1.1 1.1.2 1.1.3 1.1.4 1.1.5 1.2.0
so-css / lib / codemirror / addon / fold / indent-fold.js
so-css / lib / codemirror / addon / fold Last commit date
brace-fold.js 9 years ago brace-fold.min.js 6 years ago comment-fold.js 9 years ago comment-fold.min.js 6 years ago foldcode.js 9 years ago foldcode.min.js 6 years ago foldgutter.css 11 years ago foldgutter.js 9 years ago foldgutter.min.js 6 years ago indent-fold.js 9 years ago indent-fold.min.js 6 years ago markdown-fold.js 11 years ago markdown-fold.min.js 6 years ago xml-fold.js 9 years ago xml-fold.min.js 6 years ago
indent-fold.js
49 lines
1 // CodeMirror, copyright (c) by Marijn Haverbeke and others
2 // Distributed under an MIT license: http://codemirror.net/LICENSE
3
4 (function(mod) {
5 if (typeof exports == "object" && typeof module == "object") // CommonJS
6 mod(require("../../lib/codemirror"));
7 else if (typeof define == "function" && define.amd) // AMD
8 define(["../../lib/codemirror"], mod);
9 else // Plain browser env
10 mod(CodeMirror);
11 })(function(CodeMirror) {
12 "use strict";
13
14 function lineIndent(cm, lineNo) {
15 var text = cm.getLine(lineNo)
16 var spaceTo = text.search(/\S/)
17 if (spaceTo == -1 || /\bcomment\b/.test(cm.getTokenTypeAt(CodeMirror.Pos(lineNo, spaceTo + 1))))
18 return -1
19 return CodeMirror.countColumn(text, null, cm.getOption("tabSize"))
20 }
21 !
22 CodeMirror.registerHelper("fold", "indent", function(cm, start) {
23 var myIndent = lineIndent(cm, start.line)
24 if (myIndent < 0) return
25 var lastLineInFold = null
26
27 // Go through lines until we find a line that definitely doesn't belong in
28 // the block we're folding, or to the end.
29 for (var i = start.line + 1, end = cm.lastLine(); i <= end; ++i) {
30 var indent = lineIndent(cm, i)
31 if (indent == -1) {
32 } else if (indent > myIndent) {
33 // Lines with a greater indent are considered part of the block.
34 lastLineInFold = i;
35 } else {
36 // If this line has non-space, non-comment content, and is
37 // indented less or equal to the start line, it is the start of
38 // another block.
39 break;
40 }
41 }
42 if (lastLineInFold) return {
43 from: CodeMirror.Pos(start.line, cm.getLine(start.line).length),
44 to: CodeMirror.Pos(lastLineInFold, cm.getLine(lastLineInFold).length)
45 };
46 });
47
48 });
49