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,20 +634,22 @@ var Document = function(text, mode) {
this.moveLinesUp = function(firstRow, lastRow) {
if (firstRow <= 0) return 0;
var removed = this.lines.splice(firstRow, lastRow-firstRow+1);
this.$insertLines(firstRow-1, removed);
var removed = this.lines.slice(firstRow, lastRow + 1);
this.$remove(new Range(firstRow, 0, lastRow + 1, 0));
this.$insertLines(firstRow - 1, removed);
this.fireChangeEvent(firstRow-1, lastRow);
this.fireChangeEvent(firstRow - 1, lastRow);
return -1;
};
this.moveLinesDown = function(firstRow, lastRow) {
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.fireChangeEvent(firstRow, lastRow+1);
this.fireChangeEvent(firstRow, lastRow + 1);
return 1;
};