summaryrefslogtreecommitdiff
path: root/scene/gui
diff options
context:
space:
mode:
authorPaulo Gomes <tuga3d@gmail.com>2017-08-30 19:35:38 +0100
committerPaulo Gomes <tuga3d@gmail.com>2017-08-30 19:35:38 +0100
commit2eb46801cb8122b6767d5d756a4c4e608049694c (patch)
treedec527d23cc76ef65d325f17b7579f3c2df21cca /scene/gui
parent6611dfbd6ce9d00bc178554001f64a9ab60ff7ce (diff)
second attempt on fixing the indent glitch.
I've reverted the first attempt (https://github.com/godotengine/godot/pull/10653). I was very naive and didn't consider that the glitch happens also if you're not in the first column, ex. if you have 2 tabs and press return in between them. Hope this will solve the problem without messing anything else.
Diffstat (limited to 'scene/gui')
-rw-r--r--scene/gui/text_edit.cpp6
1 files changed, 3 insertions, 3 deletions
diff --git a/scene/gui/text_edit.cpp b/scene/gui/text_edit.cpp
index 7a9daea73e..7b93393851 100644
--- a/scene/gui/text_edit.cpp
+++ b/scene/gui/text_edit.cpp
@@ -2113,15 +2113,15 @@ void TextEdit::_gui_input(const Ref<InputEvent> &p_gui_input) {
//keep indentation
int space_count = 0;
- for (int i = 0; i < text[cursor.line].length(); i++) {
- if (text[cursor.line][i] == '\t' && cursor.column > 0) {
+ for (int i = 0; i < cursor.column; i++) {
+ if (text[cursor.line][i] == '\t') {
if (indent_using_spaces) {
ins += space_indent;
} else {
ins += "\t";
}
space_count = 0;
- } else if (text[cursor.line][i] == ' ' && cursor.column > 0) {
+ } else if (text[cursor.line][i] == ' ') {
space_count++;
if (space_count == indent_size) {