diff --git a/lib/ace/editor.js b/lib/ace/editor.js index b5c93d15579..942a6c6affd 100644 --- a/lib/ace/editor.js +++ b/lib/ace/editor.js @@ -1484,7 +1484,7 @@ var Editor = function(renderer, session) { var indentString = lang.stringRepeat(" ", count); } else { var count = column % size; - while (line[range.start.column] == " " && count) { + while (line[range.start.column - 1] == " " && count) { range.start.column--; count--; } diff --git a/lib/ace/editor_text_edit_test.js b/lib/ace/editor_text_edit_test.js index 77ec34ed2bb..382b8518af5 100644 --- a/lib/ace/editor_text_edit_test.js +++ b/lib/ace/editor_text_edit_test.js @@ -124,6 +124,12 @@ module.exports = { var range = editor.getSelectionRange(); assert.position(range.start, 1, 7); assert.position(range.end, 2, 7); + + session.setValue(" x"); + session.setOption("useSoftTabs", false); + editor.selection.moveTo(0, 3); + editor.indent(); + assert.equal("\tx", session.toString()); }, "test: indent selected lines" : function() {