MCPcopy Create free account
hub / github.com/sql-js/sql.js / copyHistoryArray

Function copyHistoryArray

GUI/codemirror/lib/codemirror.js:6751–6772  ·  view source on GitHub ↗
(events, newGroup, instantiateSel)

Source from the content-addressed store, hash-verified

6749 // Used both to provide a JSON-safe object in .getHistory, and, when
6750 // detaching a document, to split the history in two
6751 function copyHistoryArray(events, newGroup, instantiateSel) {
6752 for (var i = 0, copy = []; i < events.length; ++i) {
6753 var event = events[i];
6754 if (event.ranges) {
6755 copy.push(instantiateSel ? Selection.prototype.deepCopy.call(event) : event);
6756 continue;
6757 }
6758 var changes = event.changes, newChanges = [];
6759 copy.push({changes: newChanges});
6760 for (var j = 0; j < changes.length; ++j) {
6761 var change = changes[j], m;
6762 newChanges.push({from: change.from, to: change.to, text: change.text});
6763 if (newGroup) for (var prop in change) if (m = prop.match(/^spans_(\d+)$/)) {
6764 if (indexOf(newGroup, Number(m[1])) > -1) {
6765 lst(newChanges)[prop] = change[prop];
6766 delete change[prop];
6767 }
6768 }
6769 }
6770 }
6771 return copy;
6772 }
6773
6774 // Rebasing/resetting history to deal with externally-sourced changes
6775

Callers 1

codemirror.jsFile · 0.85

Calls 2

indexOfFunction · 0.85
lstFunction · 0.85

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…