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

Function mergeOldSpans

tools/pythonauto/static/codemirrorepl/codemirror.js:5234–5254  ·  view source on GitHub ↗
(doc, change)

Source from the content-addressed store, hash-verified

5232 // existed in the history (so that deleting around a span and then
5233 // undoing brings back the span).
5234 function mergeOldSpans(doc, change) {
5235 var old = getOldSpans(doc, change);
5236 var stretched = stretchSpansOverChange(doc, change);
5237 if (!old) return stretched;
5238 if (!stretched) return old;
5239
5240 for (var i = 0; i < old.length; ++i) {
5241 var oldCur = old[i], stretchCur = stretched[i];
5242 if (oldCur && stretchCur) {
5243 spans: for (var j = 0; j < stretchCur.length; ++j) {
5244 var span = stretchCur[j];
5245 for (var k = 0; k < oldCur.length; ++k)
5246 if (oldCur[k].marker == span.marker) continue spans;
5247 oldCur.push(span);
5248 }
5249 } else if (stretchCur) {
5250 old[i] = stretchCur;
5251 }
5252 }
5253 return old;
5254 }
5255
5256 // Used to 'clip' out readOnly ranges when making a change.
5257 function removeReadOnlyRanges(doc, from, to) {

Callers 1

makeChangeFromHistoryFunction · 0.70

Calls 2

getOldSpansFunction · 0.70
stretchSpansOverChangeFunction · 0.70

Tested by

no test coverage detected