Fix TextFiles not saving when closing the tab
This commit is contained in:
parent
fa3164e90c
commit
f33a6328b5
1 changed files with 11 additions and 7 deletions
|
@ -763,22 +763,26 @@ void ScriptEditor::_close_tab(int p_idx, bool p_save, bool p_history_back) {
|
||||||
|
|
||||||
ScriptEditorBase *current = Object::cast_to<ScriptEditorBase>(tselected);
|
ScriptEditorBase *current = Object::cast_to<ScriptEditorBase>(tselected);
|
||||||
if (current) {
|
if (current) {
|
||||||
Ref<Script> script = current->get_edited_resource();
|
RES file = current->get_edited_resource();
|
||||||
if (p_save && script.is_valid()) {
|
if (p_save && file.is_valid()) {
|
||||||
// Do not try to save internal scripts, but prompt to save in-memory
|
// Do not try to save internal scripts, but prompt to save in-memory
|
||||||
// scripts which are not saved to disk yet (have empty path).
|
// scripts which are not saved to disk yet (have empty path).
|
||||||
if (script->get_path().find("local://") == -1 && script->get_path().find("::") == -1) {
|
if (file->get_path().find("local://") == -1 && file->get_path().find("::") == -1) {
|
||||||
save_current_script();
|
save_current_script();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (script.is_valid()) {
|
if (file.is_valid()) {
|
||||||
if (!script->get_path().is_empty()) {
|
if (!file->get_path().is_empty()) {
|
||||||
// Only saved scripts can be restored.
|
// Only saved scripts can be restored.
|
||||||
previous_scripts.push_back(script->get_path());
|
previous_scripts.push_back(file->get_path());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Ref<Script> script = file;
|
||||||
|
if (script.is_valid()) {
|
||||||
notify_script_close(script);
|
notify_script_close(script);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// roll back to previous tab
|
// roll back to previous tab
|
||||||
if (p_history_back) {
|
if (p_history_back) {
|
||||||
|
|
Loading…
Reference in a new issue