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

Function makeChangeSingleDoc

src/codemirror.js:4503–4532  ·  view source on GitHub ↗
(doc, change, selAfter, spans)

Source from the content-addressed store, hash-verified

4501 // More lower-level change function, handling only a single document
4502 // (not linked ones).
4503 function makeChangeSingleDoc(doc, change, selAfter, spans) {
4504 if (doc.cm && !doc.cm.curOp)
4505 return operation(doc.cm, makeChangeSingleDoc)(doc, change, selAfter, spans);
4506
4507 if (change.to.line < doc.first) {
4508 shiftDoc(doc, change.text.length - 1 - (change.to.line - change.from.line));
4509 return;
4510 }
4511 if (change.from.line > doc.lastLine()) return;
4512
4513 // Clip the change to the size of this doc
4514 if (change.from.line < doc.first) {
4515 var shift = change.text.length - 1 - (doc.first - change.from.line);
4516 shiftDoc(doc, shift);
4517 change = {from: Pos(doc.first, 0), to: Pos(change.to.line + shift, change.to.ch),
4518 text: [lst(change.text)], origin: change.origin};
4519 }
4520 var last = doc.lastLine();
4521 if (change.to.line > last) {
4522 change = {from: change.from, to: Pos(last, getLine(doc, last).text.length),
4523 text: [change.text[0]], origin: change.origin};
4524 }
4525
4526 change.removed = getBetween(doc, change.from, change.to);
4527
4528 if (!selAfter) selAfter = computeSelAfterChange(doc, change);
4529 if (doc.cm) makeChangeSingleDocInEditor(doc.cm, change, spans);
4530 else updateDoc(doc, change, spans);
4531 setSelectionNoUndo(doc, selAfter, sel_dontScroll);
4532 }
4533
4534 // Handle the interaction of a change to a document with the editor
4535 // that this document is part of.

Callers 2

makeChangeInnerFunction · 0.85
makeChangeFromHistoryFunction · 0.85

Calls 10

operationFunction · 0.85
shiftDocFunction · 0.85
lstFunction · 0.85
getLineFunction · 0.85
getBetweenFunction · 0.85
computeSelAfterChangeFunction · 0.85
updateDocFunction · 0.85
setSelectionNoUndoFunction · 0.85
lastLineMethod · 0.80

Tested by

no test coverage detected