diff options
author | RĂ©mi Verschelde <rverschelde@gmail.com> | 2017-04-25 07:39:00 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2017-04-25 07:39:00 +0200 |
commit | 7dba15b83fb2d2bd72559356cfedfec53215c55d (patch) | |
tree | 0b8107bc9c4d4c55aa2b6e5cf73423a674c91080 | |
parent | d9eae920a928753302bd5700610c0f29f885920a (diff) | |
parent | 924bccdbd12b078721590f1fa8cb99e72765c4f9 (diff) |
Merge pull request #8527 from RameshRavone/patch-3
GDScript: Updating new script template with Indent settings
-rw-r--r-- | modules/gdscript/gd_editor.cpp | 23 |
1 files changed, 13 insertions, 10 deletions
diff --git a/modules/gdscript/gd_editor.cpp b/modules/gdscript/gd_editor.cpp index 2a3015c185..ba8df81c15 100644 --- a/modules/gdscript/gd_editor.cpp +++ b/modules/gdscript/gd_editor.cpp @@ -55,11 +55,12 @@ Ref<Script> GDScriptLanguage::get_template(const String &p_class_name, const Str "# var a = 2\n" + "# var b = \"textvar\"\n\n" + "func _ready():\n" + - "\t# Called every time the node is added to the scene.\n" + - "\t# Initialization here\n" + - "\tpass\n"; + "%TS%# Called every time the node is added to the scene.\n" + + "%TS%# Initialization here\n" + + "%TS%pass\n"; _template = _template.replace("%BASE%", p_base_class_name); + _template = _template.replace("%TS%", _get_indentation()); Ref<GDScript> script; script.instance(); @@ -2418,16 +2419,18 @@ Error GDScriptLanguage::complete_code(const String &p_code, const String &p_base String GDScriptLanguage::_get_indentation() const { #ifdef TOOLS_ENABLED - bool use_space_indentation = EDITOR_DEF("text_editor/indent/type", "Tabs") == "Tabs" ? 0 : 1; + if (SceneTree::get_singleton()->is_editor_hint()) { + 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); + 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 += " "; + String space_indent = ""; + for (int i = 0; i < indent_size; i++) { + space_indent += " "; + } + return space_indent; } - return space_indent; } #endif return "\t"; |