You've already forked godot
mirror of
https://github.com/godotengine/godot.git
synced 2025-11-05 12:10:55 +00:00
Convert indent on save
This commit is contained in:
@@ -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<Object>());
|
||||
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<Script> script = se->get_edited_script();
|
||||
if (script.is_valid())
|
||||
se->apply_code();
|
||||
@@ -2163,6 +2196,8 @@ ScriptEditor::ScriptEditor(EditorNode *p_editor) {
|
||||
|
||||
edit_pass = 0;
|
||||
trim_trailing_whitespace_on_save = false;
|
||||
convert_indent_on_save = false;
|
||||
use_space_indentation = false;
|
||||
|
||||
ScriptServer::edit_request_func = _open_script_request;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user