diff --git a/lib/ace/Selection.js b/lib/ace/Selection.js index 015057dc..7915481c 100644 --- a/lib/ace/Selection.js +++ b/lib/ace/Selection.js @@ -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() {