fix delete last line
This commit is contained in:
parent
9505a85237
commit
40d5191bb7
2 changed files with 8 additions and 4 deletions
|
|
@ -832,7 +832,7 @@ var Editor =function(renderer, session) {
|
|||
var range = new Range(rows.first, 0, rows.last+1, 0)
|
||||
else
|
||||
var range = new Range(
|
||||
rows.first-1, this.session.getLine(rows.first).length,
|
||||
rows.first-1, this.session.getLine(rows.first-1).length,
|
||||
rows.last, this.session.getLine(rows.last).length
|
||||
);
|
||||
this.session.remove(range);
|
||||
|
|
|
|||
|
|
@ -99,12 +99,16 @@ module.exports = {
|
|||
},
|
||||
|
||||
"test: delete last should also delete the new line of the previous line" : function() {
|
||||
var session = new EditSession(["a", "b", "c"].join("\n"));
|
||||
var session = new EditSession(["a", "b", "c", ""].join("\n"));
|
||||
var editor = new Editor(new MockRenderer(), session);
|
||||
|
||||
editor.moveCursorTo(2, 1);
|
||||
editor.removeLines();
|
||||
editor.moveCursorTo(3, 0);
|
||||
|
||||
editor.removeLines();
|
||||
assert.equal(session.toString(), "a\nb\nc");
|
||||
assert.position(editor.getCursorPosition(), 2, 1);
|
||||
|
||||
editor.removeLines();
|
||||
assert.equal(session.toString(), "a\nb");
|
||||
assert.position(editor.getCursorPosition(), 1, 1);
|
||||
},
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue