MCPcopy Create free account
hub / github.com/sql-js/sql.js / removeReadOnlyRanges

Function removeReadOnlyRanges

GUI/codemirror/lib/codemirror.js:5300–5326  ·  view source on GitHub ↗
(doc, from, to)

Source from the content-addressed store, hash-verified

5298
5299 // Used to 'clip' out readOnly ranges when making a change.
5300 function removeReadOnlyRanges(doc, from, to) {
5301 var markers = null;
5302 doc.iter(from.line, to.line + 1, function(line) {
5303 if (line.markedSpans) for (var i = 0; i < line.markedSpans.length; ++i) {
5304 var mark = line.markedSpans[i].marker;
5305 if (mark.readOnly && (!markers || indexOf(markers, mark) == -1))
5306 (markers || (markers = [])).push(mark);
5307 }
5308 });
5309 if (!markers) return null;
5310 var parts = [{from: from, to: to}];
5311 for (var i = 0; i < markers.length; ++i) {
5312 var mk = markers[i], m = mk.find(0);
5313 for (var j = 0; j < parts.length; ++j) {
5314 var p = parts[j];
5315 if (cmp(p.to, m.from) < 0 || cmp(p.from, m.to) > 0) continue;
5316 var newParts = [j, 1], dfrom = cmp(p.from, m.from), dto = cmp(p.to, m.to);
5317 if (dfrom < 0 || !mk.inclusiveLeft && !dfrom)
5318 newParts.push({from: p.from, to: m.from});
5319 if (dto > 0 || !mk.inclusiveRight && !dto)
5320 newParts.push({from: m.to, to: p.to});
5321 parts.splice.apply(parts, newParts);
5322 j += newParts.length - 1;
5323 }
5324 }
5325 return parts;
5326 }
5327
5328 // Connect or disconnect spans from a line.
5329 function detachMarkedSpans(line) {

Callers 1

makeChangeFunction · 0.85

Calls 1

indexOfFunction · 0.85

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…