MCPcopy Create free account
hub / github.com/ronreiter/interactive-tutorials / makeChangeFromHistory

Function makeChangeFromHistory

static/js/codemirror/codemirror.js:2147–2175  ·  view source on GitHub ↗
(doc, type)

Source from the content-addressed store, hash-verified

2145 }
2146
2147 function makeChangeFromHistory(doc, type) {
2148 var hist = doc.history;
2149 var event = (type == "undo" ? hist.done : hist.undone).pop();
2150 if (!event) return;
2151 hist.dirtyCounter += type == "undo" ? -1 : 1;
2152
2153 var anti = {changes: [], anchorBefore: event.anchorAfter, headBefore: event.headAfter,
2154 anchorAfter: event.anchorBefore, headAfter: event.headBefore};
2155 (type == "undo" ? hist.undone : hist.done).push(anti);
2156
2157 for (var i = event.changes.length - 1; i >= 0; --i) {
2158 var change = event.changes[i];
2159 change.origin = type;
2160 anti.changes.push(historyChangeFromChange(doc, change));
2161
2162 var after = i ? computeSelAfterChange(doc, change, null)
2163 : {anchor: event.anchorBefore, head: event.headBefore};
2164 makeChangeSingleDoc(doc, change, after, mergeOldSpans(doc, change));
2165 var rebased = [];
2166
2167 linkedDocs(doc, function(doc, sharedHist) {
2168 if (!sharedHist && indexOf(rebased, doc.history) == -1) {
2169 rebaseHist(doc.history, change);
2170 rebased.push(doc.history);
2171 }
2172 makeChangeSingleDoc(doc, change, null, mergeOldSpans(doc, change));
2173 });
2174 }
2175 }
2176
2177 function shiftDoc(doc, distance) {
2178 function shiftPos(pos) {return Pos(pos.line + distance, pos.ch);}

Callers 1

codemirror.jsFile · 0.85

Calls 9

historyChangeFromChangeFunction · 0.85
computeSelAfterChangeFunction · 0.85
makeChangeSingleDocFunction · 0.85
mergeOldSpansFunction · 0.85
linkedDocsFunction · 0.85
rebaseHistFunction · 0.85
indexOfFunction · 0.70
popMethod · 0.45
pushMethod · 0.45

Tested by

no test coverage detected