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

Function copyHistoryArray

tools/pythonauto/static/codemirrorepl/codemirror.js:6701–6722  ·  view source on GitHub ↗
(events, newGroup, instantiateSel)

Source from the content-addressed store, hash-verified

6699 // Used both to provide a JSON-safe object in .getHistory, and, when
6700 // detaching a document, to split the history in two
6701 function copyHistoryArray(events, newGroup, instantiateSel) {
6702 for (var i = 0, copy = []; i < events.length; ++i) {
6703 var event = events[i];
6704 if (event.ranges) {
6705 copy.push(instantiateSel ? Selection.prototype.deepCopy.call(event) : event);
6706 continue;
6707 }
6708 var changes = event.changes, newChanges = [];
6709 copy.push({changes: newChanges});
6710 for (var j = 0; j < changes.length; ++j) {
6711 var change = changes[j], m;
6712 newChanges.push({from: change.from, to: change.to, text: change.text});
6713 if (newGroup) for (var prop in change) if (m = prop.match(/^spans_(\d+)$/)) {
6714 if (indexOf(newGroup, Number(m[1])) > -1) {
6715 lst(newChanges)[prop] = change[prop];
6716 delete change[prop];
6717 }
6718 }
6719 }
6720 }
6721 return copy;
6722 }
6723
6724 // Rebasing/resetting history to deal with externally-sourced changes
6725

Callers 1

codemirror.jsFile · 0.70

Calls 2

indexOfFunction · 0.70
lstFunction · 0.70

Tested by

no test coverage detected