mirror of
https://github.com/icecoder/ICEcoder.git
synced 2026-03-25 01:37:04 +01:00
initMarks is now dontCollapse, clear non folds
initMarks was used for the intial setup of a doc with (-) marks but this idea can be extended to cover not wanting to collapse and only mark lines If a line isn't collapsable now it clears the markers for it (used when we delete text, replace with something else etc)
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
// Modified version of CodeMirror's codefold.js to show guttermarkers
|
||||
|
||||
CodeMirror.newFoldFunction = function(rangeFinder, widget, markOn, markOff, initMarks) {
|
||||
CodeMirror.newFoldFunction = function(rangeFinder, widget, markOn, markOff, dontCollapse) {
|
||||
if (widget == null) widget = "\u2194";
|
||||
if (typeof widget == "string") {
|
||||
var text = document.createTextNode(widget);
|
||||
@@ -27,6 +27,7 @@ CodeMirror.newFoldFunction = function(rangeFinder, widget, markOn, markOff, init
|
||||
if (typeof pos == "number") pos = CodeMirror.Pos(pos, 0);
|
||||
var range = rangeFinder(cm, pos);
|
||||
foldable = range && (range.from.line != range.to.line || range.from.ch != range.to.ch) ? true : false;
|
||||
if (!foldable) cm.setGutterMarker(pos.line, "CodeMirror-linenumbers", null);
|
||||
if (!range) return;
|
||||
|
||||
var present = cm.findMarksAt(range.from), cleared = 0;
|
||||
@@ -38,10 +39,10 @@ CodeMirror.newFoldFunction = function(rangeFinder, widget, markOn, markOff, init
|
||||
}
|
||||
|
||||
if (foldable) {
|
||||
cm.setGutterMarker(pos.line, "CodeMirror-linenumbers", cleared || initMarks ? markOff.cloneNode(true) : markOn.cloneNode(true));
|
||||
cm.setGutterMarker(pos.line, "CodeMirror-linenumbers", cleared || dontCollapse ? markOff.cloneNode(true) : markOn.cloneNode(true));
|
||||
}
|
||||
|
||||
if (cleared || initMarks) return;
|
||||
if (cleared || dontCollapse) return;
|
||||
var myWidget = widget.cloneNode(true);
|
||||
CodeMirror.on(myWidget, "mousedown", function() {myRange.clear();cm.setGutterMarker(pos.line, "CodeMirror-linenumbers", markOff.cloneNode(true));});
|
||||
var myRange = cm.markText(range.from, range.to, {
|
||||
|
||||
Reference in New Issue
Block a user