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

Function makeChangeSingleDocInEditor

tools/pythonauto/static/codemirror/codemirror.js:2471–2521  ·  view source on GitHub ↗
(cm, change, spans, selAfter)

Source from the content-addressed store, hash-verified

2469 }
2470
2471 function makeChangeSingleDocInEditor(cm, change, spans, selAfter) {
2472 var doc = cm.doc, display = cm.display, from = change.from, to = change.to;
2473
2474 var recomputeMaxLength = false, checkWidthStart = from.line;
2475 if (!cm.options.lineWrapping) {
2476 checkWidthStart = lineNo(visualLine(doc, getLine(doc, from.line)));
2477 doc.iter(checkWidthStart, to.line + 1, function(line) {
2478 if (line == display.maxLine) {
2479 recomputeMaxLength = true;
2480 return true;
2481 }
2482 });
2483 }
2484
2485 if (!posLess(doc.sel.head, change.from) && !posLess(change.to, doc.sel.head))
2486 cm.curOp.cursorActivity = true;
2487
2488 updateDoc(doc, change, spans, selAfter, estimateHeight(cm));
2489
2490 if (!cm.options.lineWrapping) {
2491 doc.iter(checkWidthStart, from.line + change.text.length, function(line) {
2492 var len = lineLength(doc, line);
2493 if (len > display.maxLineLength) {
2494 display.maxLine = line;
2495 display.maxLineLength = len;
2496 display.maxLineChanged = true;
2497 recomputeMaxLength = false;
2498 }
2499 });
2500 if (recomputeMaxLength) cm.curOp.updateMaxLine = true;
2501 }
2502
2503 // Adjust frontier, schedule worker
2504 doc.frontier = Math.min(doc.frontier, from.line);
2505 startWorker(cm, 400);
2506
2507 var lendiff = change.text.length - (to.line - from.line) - 1;
2508 // Remember that these lines changed, for updating the display
2509 regChange(cm, from.line, to.line + 1, lendiff);
2510
2511 if (hasHandler(cm, "change")) {
2512 var changeObj = {from: from, to: to,
2513 text: change.text,
2514 removed: change.removed,
2515 origin: change.origin};
2516 if (cm.curOp.textChanged) {
2517 for (var cur = cm.curOp.textChanged; cur.next; cur = cur.next) {}
2518 cur.next = changeObj;
2519 } else cm.curOp.textChanged = changeObj;
2520 }
2521 }
2522
2523 function replaceRange(doc, code, from, to, origin) {
2524 if (!to) to = from;

Callers 1

makeChangeSingleDocFunction · 0.70

Calls 10

lineNoFunction · 0.70
visualLineFunction · 0.70
getLineFunction · 0.70
posLessFunction · 0.70
updateDocFunction · 0.70
estimateHeightFunction · 0.70
lineLengthFunction · 0.70
startWorkerFunction · 0.70
regChangeFunction · 0.70
hasHandlerFunction · 0.70

Tested by

no test coverage detected