You've already forked godot
mirror of
https://github.com/godotengine/godot.git
synced 2025-11-05 12:10:55 +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:
@@ -119,6 +119,9 @@ String TextEditor::get_name() {
|
||||
if (text_file->get_path().find("local://") == -1 && text_file->get_path().find("::") == -1) {
|
||||
name = text_file->get_path().get_file();
|
||||
if (is_unsaved()) {
|
||||
if (text_file->get_path().empty()) {
|
||||
name = TTR("[unsaved]");
|
||||
}
|
||||
name += "(*)";
|
||||
}
|
||||
} else if (text_file->get_name() != "") {
|
||||
@@ -236,7 +239,10 @@ void TextEditor::apply_code() {
|
||||
}
|
||||
|
||||
bool TextEditor::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() ||
|
||||
text_file->get_path().empty(); // In memory.
|
||||
return unsaved;
|
||||
}
|
||||
|
||||
Variant TextEditor::get_edit_state() {
|
||||
|
||||
Reference in New Issue
Block a user