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

Function copyHistoryArray

static/js/codemirror/codemirror.js:4740–4757  ·  view source on GitHub ↗
(events, newGroup)

Source from the content-addressed store, hash-verified

4738 // Used both to provide a JSON-safe object in .getHistory, and, when
4739 // detaching a document, to split the history in two
4740 function copyHistoryArray(events, newGroup) {
4741 for (var i = 0, copy = []; i < events.length; ++i) {
4742 var event = events[i], changes = event.changes, newChanges = [];
4743 copy.push({changes: newChanges, anchorBefore: event.anchorBefore, headBefore: event.headBefore,
4744 anchorAfter: event.anchorAfter, headAfter: event.headAfter});
4745 for (var j = 0; j < changes.length; ++j) {
4746 var change = changes[j], m;
4747 newChanges.push({from: change.from, to: change.to, text: change.text});
4748 if (newGroup) for (var prop in change) if (m = prop.match(/^spans_(\d+)$/)) {
4749 if (indexOf(newGroup, Number(m[1])) > -1) {
4750 lst(newChanges)[prop] = change[prop];
4751 delete change[prop];
4752 }
4753 }
4754 }
4755 }
4756 return copy;
4757 }
4758
4759 // Rebasing/resetting history to deal with externally-sourced changes
4760

Callers 1

codemirror.jsFile · 0.85

Calls 4

lstFunction · 0.85
indexOfFunction · 0.70
pushMethod · 0.45
matchMethod · 0.45

Tested by

no test coverage detected