MCPcopy
hub / github.com/witheve/Eve / makeChangeSingleDocInEditor

Function makeChangeSingleDocInEditor

src/codemirror.js:4536–4593  ·  view source on GitHub ↗
(cm, change, spans)

Source from the content-addressed store, hash-verified

4534 // Handle the interaction of a change to a document with the editor
4535 // that this document is part of.
4536 function makeChangeSingleDocInEditor(cm, change, spans) {
4537 var doc = cm.doc, display = cm.display, from = change.from, to = change.to;
4538
4539 var recomputeMaxLength = false, checkWidthStart = from.line;
4540 if (!cm.options.lineWrapping) {
4541 checkWidthStart = lineNo(visualLine(getLine(doc, from.line)));
4542 doc.iter(checkWidthStart, to.line + 1, function(line) {
4543 if (line == display.maxLine) {
4544 recomputeMaxLength = true;
4545 return true;
4546 }
4547 });
4548 }
4549
4550 if (doc.sel.contains(change.from, change.to) > -1)
4551 signalCursorActivity(cm);
4552
4553 updateDoc(doc, change, spans, estimateHeight(cm));
4554
4555 if (!cm.options.lineWrapping) {
4556 doc.iter(checkWidthStart, from.line + change.text.length, function(line) {
4557 var len = lineLength(line);
4558 if (len > display.maxLineLength) {
4559 display.maxLine = line;
4560 display.maxLineLength = len;
4561 display.maxLineChanged = true;
4562 recomputeMaxLength = false;
4563 }
4564 });
4565 if (recomputeMaxLength) cm.curOp.updateMaxLine = true;
4566 }
4567
4568 // Adjust frontier, schedule worker
4569 doc.frontier = Math.min(doc.frontier, from.line);
4570 startWorker(cm, 400);
4571
4572 var lendiff = change.text.length - (to.line - from.line) - 1;
4573 // Remember that these lines changed, for updating the display
4574 if (change.full)
4575 regChange(cm);
4576 else if (from.line == to.line && change.text.length == 1 && !isWholeLineUpdate(cm.doc, change))
4577 regLineChange(cm, from.line, "text");
4578 else
4579 regChange(cm, from.line, to.line + 1, lendiff);
4580
4581 var changesHandler = hasHandler(cm, "changes"), changeHandler = hasHandler(cm, "change");
4582 if (changeHandler || changesHandler) {
4583 var obj = {
4584 from: from, to: to,
4585 text: change.text,
4586 removed: change.removed,
4587 origin: change.origin
4588 };
4589 if (changeHandler) signalLater(cm, "change", cm, obj);
4590 if (changesHandler) (cm.curOp.changeObjs || (cm.curOp.changeObjs = [])).push(obj);
4591 }
4592 cm.display.selForContextMenu = null;
4593 }

Callers 1

makeChangeSingleDocFunction · 0.85

Calls 14

lineNoFunction · 0.85
visualLineFunction · 0.85
getLineFunction · 0.85
signalCursorActivityFunction · 0.85
updateDocFunction · 0.85
estimateHeightFunction · 0.85
lineLengthFunction · 0.85
startWorkerFunction · 0.85
regChangeFunction · 0.85
isWholeLineUpdateFunction · 0.85
regLineChangeFunction · 0.85
hasHandlerFunction · 0.85

Tested by

no test coverage detected