backspace should eat 4 spaces when the cursor is positioned after a tab

(also for navigation and selection)
This commit is contained in:
Fabian Jakobs 2010-12-18 16:24:48 +01:00
commit b6bd3fb726
4 changed files with 52 additions and 5 deletions

View file

@ -265,13 +265,20 @@ var Selection = function(doc) {
this.moveCursorLeft = function() {
if (this.selectionLead.column == 0) {
// cursor is a line start
if (this.selectionLead.row > 0) {
this.moveCursorTo(this.selectionLead.row - 1, this.doc
.getLine(this.selectionLead.row - 1).length);
}
}
else {
this.moveCursorBy(0, -1);
var doc = this.doc;
var tabSize = doc.getTabSize();
var cursor = this.selectionLead;
if (doc.isTabStop(cursor) && doc.getLine(cursor.row).slice(cursor.column-tabSize, cursor.column).split(" ").length-1 == tabSize)
this.moveCursorBy(0, -tabSize);
else
this.moveCursorBy(0, -1);
}
};
@ -282,7 +289,13 @@ var Selection = function(doc) {
}
}
else {
this.moveCursorBy(0, 1);
var doc = this.doc;
var tabSize = doc.getTabSize();
var cursor = this.selectionLead;
if (doc.isTabStop(cursor) && doc.getLine(cursor.row).slice(cursor.column, cursor.column+tabSize).split(" ").length-1 == tabSize)
this.moveCursorBy(0, tabSize);
else
this.moveCursorBy(0, 1);
}
};