MCPcopy Create free account
hub / github.com/ronreiter/interactive-tutorials / removeReadOnlyRanges

Function removeReadOnlyRanges

static/js/codemirror/codemirror.js:3676–3702  ·  view source on GitHub ↗
(doc, from, to)

Source from the content-addressed store, hash-verified

3674 }
3675
3676 function removeReadOnlyRanges(doc, from, to) {
3677 var markers = null;
3678 doc.iter(from.line, to.line + 1, function(line) {
3679 if (line.markedSpans) for (var i = 0; i < line.markedSpans.length; ++i) {
3680 var mark = line.markedSpans[i].marker;
3681 if (mark.readOnly && (!markers || indexOf(markers, mark) == -1))
3682 (markers || (markers = [])).push(mark);
3683 }
3684 });
3685 if (!markers) return null;
3686 var parts = [{from: from, to: to}];
3687 for (var i = 0; i < markers.length; ++i) {
3688 var mk = markers[i], m = mk.find();
3689 for (var j = 0; j < parts.length; ++j) {
3690 var p = parts[j];
3691 if (posLess(p.to, m.from) || posLess(m.to, p.from)) continue;
3692 var newParts = [j, 1];
3693 if (posLess(p.from, m.from) || !mk.inclusiveLeft && posEq(p.from, m.from))
3694 newParts.push({from: p.from, to: m.from});
3695 if (posLess(m.to, p.to) || !mk.inclusiveRight && posEq(p.to, m.to))
3696 newParts.push({from: m.to, to: p.to});
3697 parts.splice.apply(parts, newParts);
3698 j += newParts.length - 1;
3699 }
3700 }
3701 return parts;
3702 }
3703
3704 function collapsedSpanAt(line, ch) {
3705 var sps = sawCollapsedSpans && line.markedSpans, found;

Callers 1

makeChangeFunction · 0.85

Calls 6

posLessFunction · 0.85
posEqFunction · 0.85
indexOfFunction · 0.70
pushMethod · 0.45
findMethod · 0.45
applyMethod · 0.45

Tested by

no test coverage detected