From c59bd79e02548533c61e1ce30e3009f7804658f7 Mon Sep 17 00:00:00 2001 From: Paulb23 Date: Mon, 17 Apr 2017 14:46:00 +0100 Subject: Convert indent on save --- editor/plugins/script_editor_plugin.cpp | 35 ++++++++++++++++++++++++++ editor/plugins/script_editor_plugin.h | 4 +++ modules/visual_script/visual_script_editor.cpp | 6 +++++ modules/visual_script/visual_script_editor.h | 2 ++ 4 files changed, 47 insertions(+) diff --git a/editor/plugins/script_editor_plugin.cpp b/editor/plugins/script_editor_plugin.cpp index bc6f2134a2..2695d9d882 100644 --- a/editor/plugins/script_editor_plugin.cpp +++ b/editor/plugins/script_editor_plugin.cpp @@ -530,6 +530,15 @@ void ScriptEditor::_resave_scripts(const String &p_str) { if (trim_trailing_whitespace_on_save) { se->trim_trailing_whitespace(); } + + if (convert_indent_on_save) { + if (use_space_indentation) { + se->convert_indent_to_spaces(); + } else { + se->convert_indent_to_tabs(); + } + } + editor->save_resource(script); se->tag_saved_version(); } @@ -795,12 +804,28 @@ void ScriptEditor::_menu_option(int p_option) { if (trim_trailing_whitespace_on_save) current->trim_trailing_whitespace(); + + if (convert_indent_on_save) { + if (use_space_indentation) { + current->convert_indent_to_spaces(); + } else { + current->convert_indent_to_tabs(); + } + } editor->save_resource(current->get_edited_script()); } break; case FILE_SAVE_AS: { current->trim_trailing_whitespace(); + + if (convert_indent_on_save) { + if (use_space_indentation) { + current->convert_indent_to_spaces(); + } else { + current->convert_indent_to_tabs(); + } + } editor->push_item(current->get_edited_script()->cast_to()); editor->save_resource_as(current->get_edited_script()); @@ -1483,6 +1508,14 @@ void ScriptEditor::save_all_scripts() { se->trim_trailing_whitespace(); } + if (convert_indent_on_save) { + if (use_space_indentation) { + se->convert_indent_to_spaces(); + } else { + se->convert_indent_to_tabs(); + } + } + Ref