MCPcopy
hub / github.com/witheve/Eve / removeReadOnlyRanges

Function removeReadOnlyRanges

src/codemirror.js:6491–6517  ·  view source on GitHub ↗
(doc, from, to)

Source from the content-addressed store, hash-verified

6489
6490 // Used to 'clip' out readOnly ranges when making a change.
6491 function removeReadOnlyRanges(doc, from, to) {
6492 var markers = null;
6493 doc.iter(from.line, to.line + 1, function(line) {
6494 if (line.markedSpans) for (var i = 0; i < line.markedSpans.length; ++i) {
6495 var mark = line.markedSpans[i].marker;
6496 if (mark.readOnly && (!markers || indexOf(markers, mark) == -1))
6497 (markers || (markers = [])).push(mark);
6498 }
6499 });
6500 if (!markers) return null;
6501 var parts = [{from: from, to: to}];
6502 for (var i = 0; i < markers.length; ++i) {
6503 var mk = markers[i], m = mk.find(0);
6504 for (var j = 0; j < parts.length; ++j) {
6505 var p = parts[j];
6506 if (cmp(p.to, m.from) < 0 || cmp(p.from, m.to) > 0) continue;
6507 var newParts = [j, 1], dfrom = cmp(p.from, m.from), dto = cmp(p.to, m.to);
6508 if (dfrom < 0 || !mk.inclusiveLeft && !dfrom)
6509 newParts.push({from: p.from, to: m.from});
6510 if (dto > 0 || !mk.inclusiveRight && !dto)
6511 newParts.push({from: m.to, to: p.to});
6512 parts.splice.apply(parts, newParts);
6513 j += newParts.length - 1;
6514 }
6515 }
6516 return parts;
6517 }
6518
6519 // Connect or disconnect spans from a line.
6520 function detachMarkedSpans(line) {

Callers 1

makeChangeFunction · 0.85

Calls 3

indexOfFunction · 0.85
findMethod · 0.65
applyMethod · 0.45

Tested by

no test coverage detected