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)
|
var range = new Range(rows.first, 0, rows.last+1, 0)
|
||||||
else
|
else
|
||||||
var range = new Range(
|
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
|
rows.last, this.session.getLine(rows.last).length
|
||||||
);
|
);
|
||||||
this.session.remove(range);
|
this.session.remove(range);
|
||||||
|
|
|
||||||
|
|
@ -99,12 +99,16 @@ module.exports = {
|
||||||
},
|
},
|
||||||
|
|
||||||
"test: delete last should also delete the new line of the previous line" : 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 session = new EditSession(["a", "b", "c", ""].join("\n"));
|
||||||
var editor = new Editor(new MockRenderer(), session);
|
var editor = new Editor(new MockRenderer(), session);
|
||||||
|
|
||||||
editor.moveCursorTo(2, 1);
|
editor.moveCursorTo(3, 0);
|
||||||
editor.removeLines();
|
|
||||||
|
|
||||||
|
editor.removeLines();
|
||||||
|
assert.equal(session.toString(), "a\nb\nc");
|
||||||
|
assert.position(editor.getCursorPosition(), 2, 1);
|
||||||
|
|
||||||
|
editor.removeLines();
|
||||||
assert.equal(session.toString(), "a\nb");
|
assert.equal(session.toString(), "a\nb");
|
||||||
assert.position(editor.getCursorPosition(), 1, 1);
|
assert.position(editor.getCursorPosition(), 1, 1);
|
||||||
},
|
},
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue