| 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 | |