(cm, change, spans)
| 3444 | // Handle the interaction of a change to a document with the editor |
| 3445 | // that this document is part of. |
| 3446 | function makeChangeSingleDocInEditor(cm, change, spans) { |
| 3447 | var doc = cm.doc, display = cm.display, from = change.from, to = change.to; |
| 3448 | |
| 3449 | var recomputeMaxLength = false, checkWidthStart = from.line; |
| 3450 | if (!cm.options.lineWrapping) { |
| 3451 | checkWidthStart = lineNo(visualLine(getLine(doc, from.line))); |
| 3452 | doc.iter(checkWidthStart, to.line + 1, function(line) { |
| 3453 | if (line == display.maxLine) { |
| 3454 | recomputeMaxLength = true; |
| 3455 | return true; |
| 3456 | } |
| 3457 | }); |
| 3458 | } |
| 3459 | |
| 3460 | if (doc.sel.contains(change.from, change.to) > -1) |
| 3461 | signalCursorActivity(cm); |
| 3462 | |
| 3463 | updateDoc(doc, change, spans, estimateHeight(cm)); |
| 3464 | |
| 3465 | if (!cm.options.lineWrapping) { |
| 3466 | doc.iter(checkWidthStart, from.line + change.text.length, function(line) { |
| 3467 | var len = lineLength(line); |
| 3468 | if (len > display.maxLineLength) { |
| 3469 | display.maxLine = line; |
| 3470 | display.maxLineLength = len; |
| 3471 | display.maxLineChanged = true; |
| 3472 | recomputeMaxLength = false; |
| 3473 | } |
| 3474 | }); |
| 3475 | if (recomputeMaxLength) cm.curOp.updateMaxLine = true; |
| 3476 | } |
| 3477 | |
| 3478 | // Adjust frontier, schedule worker |
| 3479 | doc.frontier = Math.min(doc.frontier, from.line); |
| 3480 | startWorker(cm, 400); |
| 3481 | |
| 3482 | var lendiff = change.text.length - (to.line - from.line) - 1; |
| 3483 | // Remember that these lines changed, for updating the display |
| 3484 | if (from.line == to.line && change.text.length == 1 && !isWholeLineUpdate(cm.doc, change)) |
| 3485 | regLineChange(cm, from.line, "text"); |
| 3486 | else |
| 3487 | regChange(cm, from.line, to.line + 1, lendiff); |
| 3488 | |
| 3489 | var changesHandler = hasHandler(cm, "changes"), changeHandler = hasHandler(cm, "change"); |
| 3490 | if (changeHandler || changesHandler) { |
| 3491 | var obj = { |
| 3492 | from: from, to: to, |
| 3493 | text: change.text, |
| 3494 | removed: change.removed, |
| 3495 | origin: change.origin |
| 3496 | }; |
| 3497 | if (changeHandler) signalLater(cm, "change", cm, obj); |
| 3498 | if (changesHandler) (cm.curOp.changeObjs || (cm.curOp.changeObjs = [])).push(obj); |
| 3499 | } |
| 3500 | } |
| 3501 | |
| 3502 | function replaceRange(doc, code, from, to, origin) { |
| 3503 | if (!to) to = from; |
no test coverage detected
searching dependent graphs…