(doc, change)
| 6239 | // existed in the history (so that deleting around a span and then |
| 6240 | // undoing brings back the span). |
| 6241 | function mergeOldSpans(doc, change) { |
| 6242 | var old = getOldSpans(doc, change); |
| 6243 | var stretched = stretchSpansOverChange(doc, change); |
| 6244 | if (!old) return stretched; |
| 6245 | if (!stretched) return old; |
| 6246 | |
| 6247 | for (var i = 0; i < old.length; ++i) { |
| 6248 | var oldCur = old[i], stretchCur = stretched[i]; |
| 6249 | if (oldCur && stretchCur) { |
| 6250 | spans: for (var j = 0; j < stretchCur.length; ++j) { |
| 6251 | var span = stretchCur[j]; |
| 6252 | for (var k = 0; k < oldCur.length; ++k) |
| 6253 | if (oldCur[k].marker == span.marker) continue spans; |
| 6254 | oldCur.push(span); |
| 6255 | } |
| 6256 | } else if (stretchCur) { |
| 6257 | old[i] = stretchCur; |
| 6258 | } |
| 6259 | } |
| 6260 | return old; |
| 6261 | } |
| 6262 | |
| 6263 | // Used to 'clip' out readOnly ranges when making a change. |
| 6264 | function removeReadOnlyRanges(doc, from, to) { |
no test coverage detected