From 043dfa705efb7d7b2e2fb3f1ee4427421175edcd Mon Sep 17 00:00:00 2001 From: Fabian Jakobs Date: Tue, 2 Nov 2010 19:24:01 +0100 Subject: [PATCH] fix: undo broken after move lines --- lib/ace/Document.js | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/lib/ace/Document.js b/lib/ace/Document.js index 54aa2030..13a87dba 100644 --- a/lib/ace/Document.js +++ b/lib/ace/Document.js @@ -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; };