fix: undo broken after move lines

This commit is contained in:
Fabian Jakobs 2010-11-02 19:24:01 +01:00
commit 043dfa705e

View file

@ -634,7 +634,8 @@ var Document = function(text, mode) {
this.moveLinesUp = function(firstRow, lastRow) { this.moveLinesUp = function(firstRow, lastRow) {
if (firstRow <= 0) return 0; if (firstRow <= 0) return 0;
var removed = this.lines.splice(firstRow, lastRow-firstRow+1); var removed = this.lines.slice(firstRow, lastRow + 1);
this.$remove(new Range(firstRow, 0, lastRow + 1, 0));
this.$insertLines(firstRow - 1, removed); this.$insertLines(firstRow - 1, removed);
this.fireChangeEvent(firstRow - 1, lastRow); this.fireChangeEvent(firstRow - 1, lastRow);
@ -644,7 +645,8 @@ var Document = function(text, mode) {
this.moveLinesDown = function(firstRow, lastRow) { this.moveLinesDown = function(firstRow, lastRow) {
if (lastRow >= this.lines.length-1) return 0; if (lastRow >= this.lines.length-1) return 0;
var removed = this.lines.splice(firstRow, lastRow-firstRow+1); var removed = this.lines.slice(firstRow, lastRow + 1);
this.$remove(new Range(firstRow, 0, lastRow + 1, 0));
this.$insertLines(firstRow+1, removed); this.$insertLines(firstRow+1, removed);
this.fireChangeEvent(firstRow, lastRow + 1); this.fireChangeEvent(firstRow, lastRow + 1);