(doc, change)
| 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) { |
no test coverage detected