MCPcopy Create free account
hub / github.com/TextGeneratorio/text-generator.io / copyHistoryArray

Function copyHistoryArray

static/libs/codemirror.js:4935–4957  ·  view source on GitHub ↗
(events, newGroup, instantiateSel)

Source from the content-addressed store, hash-verified

4933// Used both to provide a JSON-safe object in .getHistory, and, when
4934// detaching a document, to split the history in two
4935function copyHistoryArray(events, newGroup, instantiateSel) {
4936 var copy = [];
4937 for (var i = 0; i < events.length; ++i) {
4938 var event = events[i];
4939 if (event.ranges) {
4940 copy.push(instantiateSel ? Selection.prototype.deepCopy.call(event) : event);
4941 continue
4942 }
4943 var changes = event.changes, newChanges = [];
4944 copy.push({changes: newChanges});
4945 for (var j = 0; j < changes.length; ++j) {
4946 var change = changes[j], m = (void 0);
4947 newChanges.push({from: change.from, to: change.to, text: change.text});
4948 if (newGroup) { for (var prop in change) { if (m = prop.match(/^spans_(\d+)$/)) {
4949 if (indexOf(newGroup, Number(m[1])) > -1) {
4950 lst(newChanges)[prop] = change[prop];
4951 delete change[prop];
4952 }
4953 } } }
4954 }
4955 }
4956 return copy
4957}
4958
4959// The 'scroll' parameter given to many of these indicated whether
4960// the new cursor position should be scrolled into view after

Callers 1

codemirror.jsFile · 0.85

Calls 2

indexOfFunction · 0.85
lstFunction · 0.85

Tested by

no test coverage detected