MCPcopy
hub / github.com/hokein/electron-sample-apps / unredoHelper

Function unredoHelper

mini-code-editor/cm/lib/codemirror.js:651–665  ·  view source on GitHub ↗
(from, to)

Source from the content-addressed store, hash-verified

649 updateLinesNoUndo(from, to, newText, selFrom, selTo);
650 }
651 function unredoHelper(from, to) {
652 if (!from.length) return;
653 var set = from.pop(), out = [];
654 for (var i = set.length - 1; i >= 0; i -= 1) {
655 var change = set[i];
656 var replaced = [], end = change.start + change.added;
657 doc.iter(change.start, end, function(line) { replaced.push(line.text); });
658 out.push({start: change.start, added: change.old.length, old: replaced});
659 var pos = clipPos({line: change.start + change.old.length - 1,
660 ch: editEnd(replaced[replaced.length-1], change.old[change.old.length-1])});
661 updateLinesNoUndo({line: change.start, ch: 0}, {line: end - 1, ch: getLine(end-1).text.length}, change.old, pos, pos);
662 }
663 updateInput = true;
664 to.push(out);
665 }
666 function undo() {unredoHelper(history.done, history.undone);}
667 function redo() {unredoHelper(history.undone, history.done);}
668

Callers 2

undoFunction · 0.85
redoFunction · 0.85

Calls 4

clipPosFunction · 0.85
editEndFunction · 0.85
updateLinesNoUndoFunction · 0.85
getLineFunction · 0.85

Tested by

no test coverage detected