1
0
mirror of https://github.com/godotengine/godot.git synced 2025-11-12 13:20:55 +00:00

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.
This commit is contained in:
Paulo Gomes
2017-08-30 19:35:38 +01:00
parent 6611dfbd6c
commit 2eb46801cb

View File

@@ -2113,15 +2113,15 @@ void TextEdit::_gui_input(const Ref<InputEvent> &p_gui_input) {
//keep indentation //keep indentation
int space_count = 0; int space_count = 0;
for (int i = 0; i < text[cursor.line].length(); i++) { for (int i = 0; i < cursor.column; i++) {
if (text[cursor.line][i] == '\t' && cursor.column > 0) { if (text[cursor.line][i] == '\t') {
if (indent_using_spaces) { if (indent_using_spaces) {
ins += space_indent; ins += space_indent;
} else { } else {
ins += "\t"; ins += "\t";
} }
space_count = 0; space_count = 0;
} else if (text[cursor.line][i] == ' ' && cursor.column > 0) { } else if (text[cursor.line][i] == ' ') {
space_count++; space_count++;
if (space_count == indent_size) { if (space_count == indent_size) {