mirror of
https://github.com/godotengine/godot.git
synced 2025-10-19 16:03:29 +00:00
Make unsaved scripts in the script editor more user-friendly
Unsaved scripts were previously displayed with blank tabs, which are mostly a result of deleted or improperly moved scripts. This patch makes sure that those kind of scripts are displayed as "[unsaved]" now, and ensures that scripts are removed from the list while deleting scripts from the filesystem dock preventing the unsaved tabs to appear in the first place (a user is already prompted with "no undo" warning while deleting any file). A user is always prompted to save those "[unsaved]" scripts if they attempt to close them without saving in any case except as described above.
This commit is contained in:
parent
5700429e4e
commit
7247247522
5 changed files with 65 additions and 10 deletions
|
@ -338,7 +338,10 @@ void ScriptTextEditor::update_settings() {
|
|||
}
|
||||
|
||||
bool ScriptTextEditor::is_unsaved() {
|
||||
return code_editor->get_text_edit()->get_version() != code_editor->get_text_edit()->get_saved_version();
|
||||
const bool unsaved =
|
||||
code_editor->get_text_edit()->get_version() != code_editor->get_text_edit()->get_saved_version() ||
|
||||
script->get_path().empty(); // In memory.
|
||||
return unsaved;
|
||||
}
|
||||
|
||||
Variant ScriptTextEditor::get_edit_state() {
|
||||
|
@ -415,6 +418,9 @@ String ScriptTextEditor::get_name() {
|
|||
if (script->get_path().find("local://") == -1 && script->get_path().find("::") == -1) {
|
||||
name = script->get_path().get_file();
|
||||
if (is_unsaved()) {
|
||||
if (script->get_path().empty()) {
|
||||
name = TTR("[unsaved]");
|
||||
}
|
||||
name += "(*)";
|
||||
}
|
||||
} else if (script->get_name() != "") {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue