diff --git a/lib/ace/editor.js b/lib/ace/editor.js index cec71fcc..d992bee1 100644 --- a/lib/ace/editor.js +++ b/lib/ace/editor.js @@ -825,7 +825,10 @@ var Editor =function(renderer, session) { if (rows.last == 0 || rows.last+1 < this.session.getLength()) var range = new Range(rows.first, 0, rows.last+1, 0) else - var range = new Range(rows.first-1, 0, rows.last, this.session.getLine(rows.last)); + var range = new Range( + rows.first-1, this.session.getLine(rows.first).length, + rows.last, this.session.getLine(rows.last).length + ); this.session.remove(range); this.clearSelection(); }; diff --git a/lib/ace/editor_text_edit_test.js b/lib/ace/editor_text_edit_test.js index 76f67280..0460359c 100644 --- a/lib/ace/editor_text_edit_test.js +++ b/lib/ace/editor_text_edit_test.js @@ -67,13 +67,13 @@ module.exports = { editor.removeLines(); - assert.equal(session.toString(), "a\n"); - assert.position(editor.getCursorPosition(), 1, 0); + assert.equal(session.toString(), "a"); + assert.position(editor.getCursorPosition(), 0, 1); editor.removeLines(); - assert.equal(session.toString(), "a\n"); - assert.position(editor.getCursorPosition(), 1, 0); + assert.equal(session.toString(), ""); + assert.position(editor.getCursorPosition(), 0, 0); }, "test: delete multiple selected lines" : function() { @@ -98,15 +98,15 @@ module.exports = { assert.position(editor.getCursorPosition(), 0, 0); }, - "test: delete last" : function() { + "test: delete last should also delete the new line of the previous line" : function() { var session = new EditSession(["a", "b", "c"].join("\n")); var editor = new Editor(new MockRenderer(), session); editor.moveCursorTo(2, 1); editor.removeLines(); - assert.equal(session.toString(), "a\nb\n"); - assert.position(editor.getCursorPosition(), 2, 0); + assert.equal(session.toString(), "a\nb"); + assert.position(editor.getCursorPosition(), 1, 1); }, "test: indent block" : function() {