fix: undo broken after move lines
This commit is contained in:
parent
ab4f1c0e1a
commit
043dfa705e
1 changed files with 8 additions and 6 deletions
|
|
@ -634,20 +634,22 @@ 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.$insertLines(firstRow-1, removed);
|
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;
|
return -1;
|
||||||
};
|
};
|
||||||
|
|
||||||
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);
|
||||||
return 1;
|
return 1;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue