navigate line start: toggle between line start and text start

This commit is contained in:
Fabian Jakobs 2010-11-02 19:37:56 +01:00
commit 3e28057caf

View file

@ -260,11 +260,13 @@ var Selection = function(doc) {
var row = this.selectionLead.row;
var column = this.selectionLead.column;
var beforeCursor = this.doc.getLine(row).slice(0, column);
var leadingSpace = beforeCursor.match(/^\s+/);
if (!leadingSpace || leadingSpace[0].length >= column)
this.moveCursorTo(this.selectionLead.row, 0);
var leadingSpace = beforeCursor.match(/^\s*/);
if (leadingSpace[0].length == 0)
this.moveCursorTo(row, this.doc.getLine(row).match(/^\s*/)[0].length);
else if (leadingSpace[0].length >= column)
this.moveCursorTo(row, 0);
else
this.moveCursorTo(this.selectionLead.row, leadingSpace[0].length);
this.moveCursorTo(row, leadingSpace[0].length);
};
this.moveCursorLineEnd = function() {