MCPcopy Index your code
hub / github.com/csev/py4e / makeChangeSingleDoc

Function makeChangeSingleDoc

tools/pythonauto/static/codemirror/codemirror.js:2441–2469  ·  view source on GitHub ↗
(doc, change, selAfter, spans)

Source from the content-addressed store, hash-verified

2439 }
2440
2441 function makeChangeSingleDoc(doc, change, selAfter, spans) {
2442 if (doc.cm && !doc.cm.curOp)
2443 return operation(doc.cm, makeChangeSingleDoc)(doc, change, selAfter, spans);
2444
2445 if (change.to.line < doc.first) {
2446 shiftDoc(doc, change.text.length - 1 - (change.to.line - change.from.line));
2447 return;
2448 }
2449 if (change.from.line > doc.lastLine()) return;
2450
2451 // Clip the change to the size of this doc
2452 if (change.from.line < doc.first) {
2453 var shift = change.text.length - 1 - (doc.first - change.from.line);
2454 shiftDoc(doc, shift);
2455 change = {from: Pos(doc.first, 0), to: Pos(change.to.line + shift, change.to.ch),
2456 text: [lst(change.text)], origin: change.origin};
2457 }
2458 var last = doc.lastLine();
2459 if (change.to.line > last) {
2460 change = {from: change.from, to: Pos(last, getLine(doc, last).text.length),
2461 text: [change.text[0]], origin: change.origin};
2462 }
2463
2464 change.removed = getBetween(doc, change.from, change.to);
2465
2466 if (!selAfter) selAfter = computeSelAfterChange(doc, change, null);
2467 if (doc.cm) makeChangeSingleDocInEditor(doc.cm, change, spans, selAfter);
2468 else updateDoc(doc, change, spans, selAfter);
2469 }
2470
2471 function makeChangeSingleDocInEditor(cm, change, spans, selAfter) {
2472 var doc = cm.doc, display = cm.display, from = change.from, to = change.to;

Callers 2

makeChangeNoReadonlyFunction · 0.70
makeChangeFromHistoryFunction · 0.70

Calls 9

PosFunction · 0.85
operationFunction · 0.70
shiftDocFunction · 0.70
lstFunction · 0.70
getLineFunction · 0.70
getBetweenFunction · 0.70
computeSelAfterChangeFunction · 0.70
updateDocFunction · 0.70

Tested by

no test coverage detected