Skip to content

armgit / godot

Public Imported from GitHub
0

Godot Engine – Multi-platform 2D and 3D game engine

Fix broken early return in GDScript auto indent

HolonProductioneb2b63f251d0
diff --git a/modules/gdscript/gdscript_editor.cpp b/modules/gdscript/gdscript_editor.cpp
index cf2c49846a3..b717c58cd06 100644
--- a/modules/gdscript/gdscript_editor.cpp
+++ b/modules/gdscript/gdscript_editor.cpp
@@ -3925,22 +3925,16 @@ void GDScriptEditorLanguage::format_code(String &r_code, uint32_t p_from_line, u
}
}
- if (i >= p_from_line) {
- l = indent.repeat(indent_stack.size()) + st;
- } else if (i > p_to_line) {
+ if (i > p_to_line) {
break;
+ } else if (i >= p_from_line) {
+ l = indent.repeat(indent_stack.size()) + st;
}
lines.write[i] = l;
}
- r_code = String();
- for (int i = 0; i < lines.size(); i++) {
- if (i > 0) {
- r_code += "\n";
- }
- r_code += lines[i];
- }
+ r_code = String("\n").join(lines);
}
static Error _lookup_symbol_from_base(const GDScriptParser::DataType &p_base, const String &p_symbol, EditorLanguage::LookupResult &r_result) {