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

Function addToHistory

tools/pythonauto/static/codemirror/codemirror.js:5331–5368  ·  view source on GitHub ↗
(doc, change, selAfter, opId)

Source from the content-addressed store, hash-verified

5329 }
5330
5331 function addToHistory(doc, change, selAfter, opId) {
5332 var hist = doc.history;
5333 hist.undone.length = 0;
5334 var time = +new Date, cur = lst(hist.done);
5335
5336 if (cur &&
5337 (hist.lastOp == opId ||
5338 hist.lastOrigin == change.origin && change.origin &&
5339 ((change.origin.charAt(0) == "+" && doc.cm && hist.lastTime > time - doc.cm.options.historyEventDelay) ||
5340 change.origin.charAt(0) == "*"))) {
5341 // Merge this change into the last event
5342 var last = lst(cur.changes);
5343 if (posEq(change.from, change.to) && posEq(change.from, last.to)) {
5344 // Optimized case for simple insertion -- don't want to add
5345 // new changesets for every character typed
5346 last.to = changeEnd(change);
5347 } else {
5348 // Add new sub-event
5349 cur.changes.push(historyChangeFromChange(doc, change));
5350 }
5351 cur.anchorAfter = selAfter.anchor; cur.headAfter = selAfter.head;
5352 } else {
5353 // Can not be merged, start a new event.
5354 cur = {changes: [historyChangeFromChange(doc, change)],
5355 generation: hist.generation,
5356 anchorBefore: doc.sel.anchor, headBefore: doc.sel.head,
5357 anchorAfter: selAfter.anchor, headAfter: selAfter.head};
5358 hist.done.push(cur);
5359 while (hist.done.length > hist.undoDepth)
5360 hist.done.shift();
5361 }
5362 hist.generation = ++hist.maxGeneration;
5363 hist.lastTime = time;
5364 hist.lastOp = opId;
5365 hist.lastOrigin = change.origin;
5366
5367 if (!last) signal(doc, "historyAdded");
5368 }
5369
5370 function removeClearedSpans(spans) {
5371 if (!spans) return null;

Callers 2

makeChangeNoReadonlyFunction · 0.85
markTextFunction · 0.85

Calls 5

signalFunction · 0.85
lstFunction · 0.70
posEqFunction · 0.70
historyChangeFromChangeFunction · 0.70
shiftMethod · 0.45

Tested by

no test coverage detected