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

Function makeChangeFromHistory

tools/pythonauto/static/codemirror/codemirror.js:2393–2431  ·  view source on GitHub ↗
(doc, type)

Source from the content-addressed store, hash-verified

2391 }
2392
2393 function makeChangeFromHistory(doc, type) {
2394 if (doc.cm && doc.cm.state.suppressEdits) return;
2395
2396 var hist = doc.history;
2397 var event = (type == "undo" ? hist.done : hist.undone).pop();
2398 if (!event) return;
2399
2400 var anti = {changes: [], anchorBefore: event.anchorAfter, headBefore: event.headAfter,
2401 anchorAfter: event.anchorBefore, headAfter: event.headBefore,
2402 generation: hist.generation};
2403 (type == "undo" ? hist.undone : hist.done).push(anti);
2404 hist.generation = event.generation || ++hist.maxGeneration;
2405
2406 var filter = hasHandler(doc, "beforeChange") || doc.cm && hasHandler(doc.cm, "beforeChange");
2407
2408 for (var i = event.changes.length - 1; i >= 0; --i) {
2409 var change = event.changes[i];
2410 change.origin = type;
2411 if (filter && !filterChange(doc, change, false)) {
2412 (type == "undo" ? hist.done : hist.undone).length = 0;
2413 return;
2414 }
2415
2416 anti.changes.push(historyChangeFromChange(doc, change));
2417
2418 var after = i ? computeSelAfterChange(doc, change, null)
2419 : {anchor: event.anchorBefore, head: event.headBefore};
2420 makeChangeSingleDoc(doc, change, after, mergeOldSpans(doc, change));
2421 var rebased = [];
2422
2423 linkedDocs(doc, function(doc, sharedHist) {
2424 if (!sharedHist && indexOf(rebased, doc.history) == -1) {
2425 rebaseHist(doc.history, change);
2426 rebased.push(doc.history);
2427 }
2428 makeChangeSingleDoc(doc, change, null, mergeOldSpans(doc, change));
2429 });
2430 }
2431 }
2432
2433 function shiftDoc(doc, distance) {
2434 function shiftPos(pos) {return Pos(pos.line + distance, pos.ch);}

Callers 1

codemirror.jsFile · 0.70

Calls 9

hasHandlerFunction · 0.70
filterChangeFunction · 0.70
historyChangeFromChangeFunction · 0.70
computeSelAfterChangeFunction · 0.70
makeChangeSingleDocFunction · 0.70
mergeOldSpansFunction · 0.70
linkedDocsFunction · 0.70
indexOfFunction · 0.70
rebaseHistFunction · 0.70

Tested by

no test coverage detected