Updates to the fold code function to standardise folding

Orig pull request approved by Marijn and merged into CodeMirror repo
(Not this one, but my previous fix)
This commit is contained in:
Matt Pass
2012-04-19 17:25:56 +01:00
parent 222f651d68
commit be20e8f302

View File

@@ -37,7 +37,7 @@ CodeMirror.tagRangeFinder = function(cm, line) {
if (-1 != slash && slash < gt) {
var str = lineText.substr(slash, gt - slash + 1);
if (!str.match( /\/\s*\>/ )) // yep, that's the end of empty tag
return l+1;
return l;
}
}
l++;
@@ -96,7 +96,7 @@ CodeMirror.tagRangeFinder = function(cm, line) {
else
depth++;
if (!depth)
return l+1;
return l;
}
}
l++;
@@ -144,7 +144,7 @@ CodeMirror.indentRangeFinder = function(cm, line) {
return last + 1;
};
CodeMirror.newFoldFunction = function(rangeFinder, markText) {
CodeMirror.newFoldFunction = function(rangeFinder, markText, hideEnd) {
var folded = [];
if (markText == null) markText = '<div style="position: absolute; left: 2px; color:#600">&#x25bc;</div>%N%';
@@ -170,6 +170,8 @@ CodeMirror.newFoldFunction = function(rangeFinder, markText) {
expand(cm, known.region);
} else {
var end = rangeFinder(cm, line);
if (rangeFinder !== CodeMirror.indentRangeFinder && hideEnd === true) end++;
console.log(rangeFinder !== CodeMirror.indentRangeFinder);
if (end == null) return;
var hidden = [];
for (var i = line + 1; i < end; ++i) {