MCPcopy Create free account
hub / github.com/OpenEndedGroup/Field2 / copyHistoryArray

Function copyHistoryArray

lib/web/CodeMirror/src/model/history.js:206–228  ·  view source on GitHub ↗
(events, newGroup, instantiateSel)

Source from the content-addressed store, hash-verified

204// Used both to provide a JSON-safe object in .getHistory, and, when
205// detaching a document, to split the history in two
206export function copyHistoryArray(events, newGroup, instantiateSel) {
207 let copy = []
208 for (let i = 0; i < events.length; ++i) {
209 let event = events[i]
210 if (event.ranges) {
211 copy.push(instantiateSel ? Selection.prototype.deepCopy.call(event) : event)
212 continue
213 }
214 let changes = event.changes, newChanges = []
215 copy.push({changes: newChanges})
216 for (let j = 0; j < changes.length; ++j) {
217 let change = changes[j], m
218 newChanges.push({from: change.from, to: change.to, text: change.text})
219 if (newGroup) for (var prop in change) if (m = prop.match(/^spans_(\d+)$/)) {
220 if (indexOf(newGroup, Number(m[1])) > -1) {
221 lst(newChanges)[prop] = change[prop]
222 delete change[prop]
223 }
224 }
225 }
226 }
227 return copy
228}

Callers 1

Doc.jsFile · 0.90

Calls 5

indexOfFunction · 0.90
lstFunction · 0.90
pushMethod · 0.45
callMethod · 0.45
matchMethod · 0.45

Tested by

no test coverage detected