|
@@ -551,7 +551,7 @@ void ScriptEditor::_close_tab(int p_idx, bool p_save, bool p_history_back) {
|
|
if (p_save) {
|
|
if (p_save) {
|
|
// Do not try to save internal scripts
|
|
// Do not try to save internal scripts
|
|
if (!script.is_valid() || !(script->get_path() == "" || script->get_path().find("local://") != -1 || script->get_path().find("::") != -1)) {
|
|
if (!script.is_valid() || !(script->get_path() == "" || script->get_path().find("local://") != -1 || script->get_path().find("::") != -1)) {
|
|
- _save_current_script();
|
|
|
|
|
|
+ save_current_script();
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
@@ -948,39 +948,6 @@ bool ScriptEditor::is_scripts_panel_toggled() {
|
|
return list_split->is_visible();
|
|
return list_split->is_visible();
|
|
}
|
|
}
|
|
|
|
|
|
-void ScriptEditor::_save_current_script() {
|
|
|
|
- ScriptEditorBase *current = _get_current_editor();
|
|
|
|
-
|
|
|
|
- if (_test_script_times_on_disk()) {
|
|
|
|
- return;
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- if (trim_trailing_whitespace_on_save) {
|
|
|
|
- current->trim_trailing_whitespace();
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- current->insert_final_newline();
|
|
|
|
-
|
|
|
|
- if (convert_indent_on_save) {
|
|
|
|
- if (use_space_indentation) {
|
|
|
|
- current->convert_indent_to_spaces();
|
|
|
|
- } else {
|
|
|
|
- current->convert_indent_to_tabs();
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- RES resource = current->get_edited_resource();
|
|
|
|
- Ref<TextFile> text_file = resource;
|
|
|
|
-
|
|
|
|
- if (text_file != nullptr) {
|
|
|
|
- current->apply_code();
|
|
|
|
- _save_text_file(text_file, text_file->get_path());
|
|
|
|
- return;
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- editor->save_resource(resource);
|
|
|
|
-}
|
|
|
|
-
|
|
|
|
void ScriptEditor::_menu_option(int p_option) {
|
|
void ScriptEditor::_menu_option(int p_option) {
|
|
ScriptEditorBase *current = _get_current_editor();
|
|
ScriptEditorBase *current = _get_current_editor();
|
|
switch (p_option) {
|
|
switch (p_option) {
|
|
@@ -1122,7 +1089,7 @@ void ScriptEditor::_menu_option(int p_option) {
|
|
if (current) {
|
|
if (current) {
|
|
switch (p_option) {
|
|
switch (p_option) {
|
|
case FILE_SAVE: {
|
|
case FILE_SAVE: {
|
|
- _save_current_script();
|
|
|
|
|
|
+ save_current_script();
|
|
} break;
|
|
} break;
|
|
case FILE_SAVE_AS: {
|
|
case FILE_SAVE_AS: {
|
|
if (trim_trailing_whitespace_on_save) {
|
|
if (trim_trailing_whitespace_on_save) {
|
|
@@ -2182,6 +2149,39 @@ bool ScriptEditor::edit(const RES &p_resource, int p_line, int p_col, bool p_gra
|
|
return true;
|
|
return true;
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+void ScriptEditor::save_current_script() {
|
|
|
|
+ ScriptEditorBase *current = _get_current_editor();
|
|
|
|
+
|
|
|
|
+ if (_test_script_times_on_disk()) {
|
|
|
|
+ return;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ if (trim_trailing_whitespace_on_save) {
|
|
|
|
+ current->trim_trailing_whitespace();
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ current->insert_final_newline();
|
|
|
|
+
|
|
|
|
+ if (convert_indent_on_save) {
|
|
|
|
+ if (use_space_indentation) {
|
|
|
|
+ current->convert_indent_to_spaces();
|
|
|
|
+ } else {
|
|
|
|
+ current->convert_indent_to_tabs();
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ RES resource = current->get_edited_resource();
|
|
|
|
+ Ref<TextFile> text_file = resource;
|
|
|
|
+
|
|
|
|
+ if (text_file != nullptr) {
|
|
|
|
+ current->apply_code();
|
|
|
|
+ _save_text_file(text_file, text_file->get_path());
|
|
|
|
+ return;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ editor->save_resource(resource);
|
|
|
|
+}
|
|
|
|
+
|
|
void ScriptEditor::save_all_scripts() {
|
|
void ScriptEditor::save_all_scripts() {
|
|
for (int i = 0; i < tab_container->get_child_count(); i++) {
|
|
for (int i = 0; i < tab_container->get_child_count(); i++) {
|
|
ScriptEditorBase *se = Object::cast_to<ScriptEditorBase>(tab_container->get_child(i));
|
|
ScriptEditorBase *se = Object::cast_to<ScriptEditorBase>(tab_container->get_child(i));
|
|
@@ -2292,7 +2292,7 @@ void ScriptEditor::_add_callback(Object *p_obj, const String &p_function, const
|
|
script_list->select(script_list->find_metadata(i));
|
|
script_list->select(script_list->find_metadata(i));
|
|
|
|
|
|
// Save the current script so the changes can be picked up by an external editor.
|
|
// Save the current script so the changes can be picked up by an external editor.
|
|
- _save_current_script();
|
|
|
|
|
|
+ save_current_script();
|
|
|
|
|
|
break;
|
|
break;
|
|
}
|
|
}
|