Rename function doFold and new namespace

doFold seems a better name, so renamed and rangeFinder var now foldType
New namespace convention on folding, also specifying type by foldType
This commit is contained in:
Matt Pass
2014-05-22 07:05:44 +01:00
parent 57a789f046
commit 05daab79c1

View File

@@ -1,6 +1,7 @@
// Modified version of CodeMirror's codefold.js to show guttermarkers
CodeMirror.newFoldFunction = function(rangeFinder, widget, markOn, markOff, dontCollapse) {
CodeMirror.doFold = function(foldType, widget, markOn, markOff, dontCollapse) {
if (widget == null) widget = "\u2194";
if (typeof widget == "string") {
var text = document.createTextNode(widget);
@@ -25,7 +26,7 @@ CodeMirror.newFoldFunction = function(rangeFinder, widget, markOn, markOff, dont
return function(cm, pos) {
if (typeof pos == "number") pos = CodeMirror.Pos(pos, 0);
var range = rangeFinder(cm, pos);
var range = CodeMirror.fold[foldType](cm, pos);
foldable = range && (range.from.line != range.to.line || range.from.ch != range.to.ch) ? true : false;
if (!foldable) cm.setGutterMarker(pos.line, "folds", null);
if (!range) return;