MCPcopy Index your code
hub / github.com/csev/py4e / removeReadOnlyRanges

Function removeReadOnlyRanges

tools/pythonauto/static/codemirrorepl/codemirror.js:5257–5283  ·  view source on GitHub ↗
(doc, from, to)

Source from the content-addressed store, hash-verified

5255
5256 // Used to 'clip' out readOnly ranges when making a change.
5257 function removeReadOnlyRanges(doc, from, to) {
5258 var markers = null;
5259 doc.iter(from.line, to.line + 1, function(line) {
5260 if (line.markedSpans) for (var i = 0; i < line.markedSpans.length; ++i) {
5261 var mark = line.markedSpans[i].marker;
5262 if (mark.readOnly && (!markers || indexOf(markers, mark) == -1))
5263 (markers || (markers = [])).push(mark);
5264 }
5265 });
5266 if (!markers) return null;
5267 var parts = [{from: from, to: to}];
5268 for (var i = 0; i < markers.length; ++i) {
5269 var mk = markers[i], m = mk.find(0);
5270 for (var j = 0; j < parts.length; ++j) {
5271 var p = parts[j];
5272 if (cmp(p.to, m.from) < 0 || cmp(p.from, m.to) > 0) continue;
5273 var newParts = [j, 1], dfrom = cmp(p.from, m.from), dto = cmp(p.to, m.to);
5274 if (dfrom < 0 || !mk.inclusiveLeft && !dfrom)
5275 newParts.push({from: p.from, to: m.from});
5276 if (dto > 0 || !mk.inclusiveRight && !dto)
5277 newParts.push({from: m.to, to: p.to});
5278 parts.splice.apply(parts, newParts);
5279 j += newParts.length - 1;
5280 }
5281 }
5282 return parts;
5283 }
5284
5285 // Connect or disconnect spans from a line.
5286 function detachMarkedSpans(line) {

Callers 1

makeChangeFunction · 0.70

Calls 3

cmpFunction · 0.85
indexOfFunction · 0.70
findMethod · 0.45

Tested by

no test coverage detected