From 80cf968cfc0f297c6a40272b01bba26d55a54ad7 Mon Sep 17 00:00:00 2001 From: nightwing Date: Tue, 12 Jul 2016 00:05:30 +0400 Subject: [PATCH] fix indent removing text before cursor --- lib/ace/editor.js | 2 +- lib/ace/editor_text_edit_test.js | 6 ++++++ 2 files changed, 7 insertions(+), 1 deletion(-) 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() {