change "delete last line" behavior to match vim
This commit is contained in:
parent
85ce847fab
commit
a39ab0d607
2 changed files with 11 additions and 8 deletions
|
|
@ -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();
|
||||
};
|
||||
|
|
|
|||
|
|
@ -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() {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue