MCPcopy Create free account
hub / github.com/TruthHun/BookStack / makeChangeSingleDoc

Function makeChangeSingleDoc

static/mergely/lib/codemirror.js:4480–4509  ·  view source on GitHub ↗
(doc, change, selAfter, spans)

Source from the content-addressed store, hash-verified

4478 // More lower-level change function, handling only a single document
4479 // (not linked ones).
4480 function makeChangeSingleDoc(doc, change, selAfter, spans) {
4481 if (doc.cm && !doc.cm.curOp)
4482 return operation(doc.cm, makeChangeSingleDoc)(doc, change, selAfter, spans);
4483
4484 if (change.to.line < doc.first) {
4485 shiftDoc(doc, change.text.length - 1 - (change.to.line - change.from.line));
4486 return;
4487 }
4488 if (change.from.line > doc.lastLine()) return;
4489
4490 // Clip the change to the size of this doc
4491 if (change.from.line < doc.first) {
4492 var shift = change.text.length - 1 - (doc.first - change.from.line);
4493 shiftDoc(doc, shift);
4494 change = {from: Pos(doc.first, 0), to: Pos(change.to.line + shift, change.to.ch),
4495 text: [lst(change.text)], origin: change.origin};
4496 }
4497 var last = doc.lastLine();
4498 if (change.to.line > last) {
4499 change = {from: change.from, to: Pos(last, getLine(doc, last).text.length),
4500 text: [change.text[0]], origin: change.origin};
4501 }
4502
4503 change.removed = getBetween(doc, change.from, change.to);
4504
4505 if (!selAfter) selAfter = computeSelAfterChange(doc, change);
4506 if (doc.cm) makeChangeSingleDocInEditor(doc.cm, change, spans);
4507 else updateDoc(doc, change, spans);
4508 setSelectionNoUndo(doc, selAfter, sel_dontScroll);
4509 }
4510
4511 // Handle the interaction of a change to a document with the editor
4512 // that this document is part of.

Callers 2

makeChangeInnerFunction · 0.70
makeChangeFromHistoryFunction · 0.70

Calls 9

operationFunction · 0.70
shiftDocFunction · 0.70
lstFunction · 0.70
getLineFunction · 0.70
getBetweenFunction · 0.70
computeSelAfterChangeFunction · 0.70
updateDocFunction · 0.70
setSelectionNoUndoFunction · 0.70

Tested by

no test coverage detected