diff options
author | Paulb23 <p_batty@hotmail.co.uk> | 2017-04-17 14:24:30 +0100 |
---|---|---|
committer | Paulb23 <p_batty@hotmail.co.uk> | 2017-04-18 12:30:46 +0100 |
commit | 84bca4e72f191450a794de795de7142da87495c6 (patch) | |
tree | ccc3682f85292cdeef8187bd2bb434acedfd1f90 /modules/gdscript/gd_editor.cpp | |
parent | 95a2a7e525a1a981b54292d64639545df61deebe (diff) | |
download | redot-engine-84bca4e72f191450a794de795de7142da87495c6.tar.gz |
Added support for space indentation
Diffstat (limited to 'modules/gdscript/gd_editor.cpp')
-rw-r--r-- | modules/gdscript/gd_editor.cpp | 25 |
1 files changed, 23 insertions, 2 deletions
diff --git a/modules/gdscript/gd_editor.cpp b/modules/gdscript/gd_editor.cpp index ae5bb5694c..c2f14f5466 100644 --- a/modules/gdscript/gd_editor.cpp +++ b/modules/gdscript/gd_editor.cpp @@ -27,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" @@ -2391,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; @@ -2432,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) { |