summaryrefslogtreecommitdiff
path: root/modules/gdscript/gd_editor.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'modules/gdscript/gd_editor.cpp')
-rw-r--r--modules/gdscript/gd_editor.cpp28
1 files changed, 25 insertions, 3 deletions
diff --git a/modules/gdscript/gd_editor.cpp b/modules/gdscript/gd_editor.cpp
index 702876ecdc..c2f14f5466 100644
--- a/modules/gdscript/gd_editor.cpp
+++ b/modules/gdscript/gd_editor.cpp
@@ -6,6 +6,7 @@
/* http://www.godotengine.org */
/*************************************************************************/
/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */
/* */
/* Permission is hereby granted, free of charge, to any person obtaining */
/* a copy of this software and associated documentation files (the */
@@ -26,6 +27,7 @@
/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/*************************************************************************/
+#include "editor/editor_settings.h"
#include "gd_compiler.h"
#include "gd_script.h"
#include "global_config.h"
@@ -1070,7 +1072,7 @@ static bool _guess_identifier_type(GDCompletionContext &context, int p_line, con
//return _guess_expression_type(context,context._class->variables[i].expression,context._class->variables[i].line,r_type);
}
- //try to guess from assignment in construtor or _ready
+ //try to guess from assignment in constructor or _ready
if (_guess_identifier_from_assignment_in_function(context, p_line + 1, p_identifier, "_ready", r_type))
return true;
if (_guess_identifier_from_assignment_in_function(context, p_line + 1, p_identifier, "_enter_tree", r_type))
@@ -2390,8 +2392,27 @@ Error GDScriptLanguage::complete_code(const String &p_code, const String &p_base
#endif
+String GDScriptLanguage::_get_indentation() const {
+#ifdef TOOLS_ENABLED
+ bool use_space_indentation = EDITOR_DEF("text_editor/indent/type", "Tabs") == "Tabs" ? 0 : 1;
+
+ if (use_space_indentation) {
+ int indent_size = EDITOR_DEF("text_editor/indent/size", 4);
+
+ String space_indent = "";
+ for (int i = 0; i < indent_size; i++) {
+ space_indent += " ";
+ }
+ return space_indent;
+ }
+#endif
+ return "\t";
+}
+
void GDScriptLanguage::auto_indent_code(String &p_code, int p_from_line, int p_to_line) const {
+ String indent = _get_indentation();
+
Vector<String> lines = p_code.split("\n");
List<int> indent_stack;
@@ -2431,8 +2452,9 @@ void GDScriptLanguage::auto_indent_code(String &p_code, int p_from_line, int p_t
if (i >= p_from_line) {
l = "";
- for (int j = 0; j < indent_stack.size(); j++)
- l += "\t";
+ for (int j = 0; j < indent_stack.size(); j++) {
+ l += indent;
+ }
l += st;
} else if (i > p_to_line) {