MCPcopy Index your code
hub / github.com/DHTMLX/gantt / makeChangeSingleDoc

Function makeChangeSingleDoc

samples/common/codehighlight/codemirror.js:5392–5424  ·  view source on GitHub ↗
(doc, change, selAfter, spans)

Source from the content-addressed store, hash-verified

5390 // More lower-level change function, handling only a single document
5391 // (not linked ones).
5392 function makeChangeSingleDoc(doc, change, selAfter, spans) {
5393 if (doc.cm && !doc.cm.curOp)
5394 { return operation(doc.cm, makeChangeSingleDoc)(doc, change, selAfter, spans) }
5395
5396 if (change.to.line < doc.first) {
5397 shiftDoc(doc, change.text.length - 1 - (change.to.line - change.from.line));
5398 return
5399 }
5400 if (change.from.line > doc.lastLine()) { return }
5401
5402 // Clip the change to the size of this doc
5403 if (change.from.line < doc.first) {
5404 var shift = change.text.length - 1 - (doc.first - change.from.line);
5405 shiftDoc(doc, shift);
5406 change = {from: Pos(doc.first, 0), to: Pos(change.to.line + shift, change.to.ch),
5407 text: [lst(change.text)], origin: change.origin};
5408 }
5409 var last = doc.lastLine();
5410 if (change.to.line > last) {
5411 change = {from: change.from, to: Pos(last, getLine(doc, last).text.length),
5412 text: [change.text[0]], origin: change.origin};
5413 }
5414
5415 change.removed = getBetween(doc, change.from, change.to);
5416
5417 if (!selAfter) { selAfter = computeSelAfterChange(doc, change); }
5418 if (doc.cm) { makeChangeSingleDocInEditor(doc.cm, change, spans); }
5419 else { updateDoc(doc, change, spans); }
5420 setSelectionNoUndo(doc, selAfter, sel_dontScroll);
5421
5422 if (doc.cantEdit && skipAtomic(doc, Pos(doc.firstLine(), 0)))
5423 { doc.cantEdit = false; }
5424 }
5425
5426 // Handle the interaction of a change to a document with the editor
5427 // that this document is part of.

Callers 2

makeChangeInnerFunction · 0.85
loopFunction · 0.85

Calls 11

operationFunction · 0.85
shiftDocFunction · 0.85
PosFunction · 0.85
lstFunction · 0.85
getLineFunction · 0.85
getBetweenFunction · 0.85
computeSelAfterChangeFunction · 0.85
updateDocFunction · 0.85
setSelectionNoUndoFunction · 0.85
skipAtomicFunction · 0.85

Tested by

no test coverage detected