summaryrefslogtreecommitdiffstats
path: root/editor/editor_file_system.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'editor/editor_file_system.cpp')
-rw-r--r--editor/editor_file_system.cpp65
1 files changed, 52 insertions, 13 deletions
diff --git a/editor/editor_file_system.cpp b/editor/editor_file_system.cpp
index b1b64b5d60..87053acfb6 100644
--- a/editor/editor_file_system.cpp
+++ b/editor/editor_file_system.cpp
@@ -42,6 +42,7 @@
#include "editor/editor_paths.h"
#include "editor/editor_resource_preview.h"
#include "editor/editor_settings.h"
+#include "editor/plugins/script_editor_plugin.h"
#include "editor/project_settings_editor.h"
#include "scene/resources/packed_scene.h"
@@ -806,18 +807,11 @@ bool EditorFileSystem::_update_scan_actions() {
case ItemAction::ACTION_FILE_RELOAD: {
int idx = ia.dir->find_file_index(ia.file);
ERR_CONTINUE(idx == -1);
- String full_path = ia.dir->get_file_path(idx);
- const EditorFileSystemDirectory::FileInfo *fi = ia.dir->files[idx];
- if (ClassDB::is_parent_class(fi->type, SNAME("Script"))) {
- _queue_update_script_class(full_path, fi->type, fi->script_class_name, fi->script_class_extends, fi->script_class_icon_path);
- }
- if (fi->type == SNAME("PackedScene")) {
- _queue_update_scene_groups(full_path);
+ // Only reloads the resources that are already loaded.
+ if (ResourceCache::has(ia.dir->get_file_path(idx))) {
+ reloads.push_back(ia.dir->get_file_path(idx));
}
-
- reloads.push_back(full_path);
-
} break;
}
@@ -841,7 +835,7 @@ bool EditorFileSystem::_update_scan_actions() {
}
}
- if (reimports.size()) {
+ if (!reimports.is_empty()) {
if (_scan_import_support(reimports)) {
return true;
}
@@ -852,6 +846,11 @@ bool EditorFileSystem::_update_scan_actions() {
ResourceUID::get_singleton()->update_cache();
}
+ if (!reloads.is_empty()) {
+ // Update global class names, dependencies, etc...
+ update_files(reloads);
+ }
+
if (first_scan) {
//only on first scan this is valid and updated, then settings changed.
revalidate_import_files = false;
@@ -1341,8 +1340,7 @@ void EditorFileSystem::_scan_fs_changes(EditorFileSystemDirectory *p_dir, ScanPr
ia.file = p_dir->files[i]->file;
scan_actions.push_back(ia);
}
- } else if (ResourceCache::has(path)) { //test for potential reload
-
+ } else {
uint64_t mt = FileAccess::get_modified_time(path);
if (mt != p_dir->files[i]->modified_time) {
@@ -1967,6 +1965,14 @@ void EditorFileSystem::_update_script_documentation() {
for (int i = 0; i < ScriptServer::get_language_count(); i++) {
ScriptLanguage *lang = ScriptServer::get_language(i);
if (lang->supports_documentation() && efd->files[index]->type == lang->get_type()) {
+ // Reloading the script from disk if resource already in memory. Otherwise, the
+ // ResourceLoader::load will return the last loaded version of the script (without the modifications).
+ // The only have the script already loaded here is to edit the script outside the
+ // editor without being connected to the LSP server.
+ Ref<Resource> res = ResourceCache::get_ref(path);
+ if (res.is_valid()) {
+ res->reload_from_file();
+ }
Ref<Script> scr = ResourceLoader::load(path);
if (scr.is_null()) {
continue;
@@ -1974,6 +1980,10 @@ void EditorFileSystem::_update_script_documentation() {
Vector<DocData::ClassDoc> docs = scr->get_documentation();
for (int j = 0; j < docs.size(); j++) {
EditorHelp::get_doc_data()->add_doc(docs[j]);
+ if (!first_scan) {
+ // Update the documentation in the Script Editor if it is open.
+ ScriptEditor::get_singleton()->update_doc(docs[j].name);
+ }
}
}
}
@@ -3057,6 +3067,35 @@ void EditorFileSystem::move_group_file(const String &p_path, const String &p_new
}
}
+void EditorFileSystem::add_new_directory(const String &p_path) {
+ String path = p_path.get_base_dir();
+ EditorFileSystemDirectory *parent = filesystem;
+ int base = p_path.count("/");
+ int max_bit = base + 1;
+
+ while (path != "res://") {
+ EditorFileSystemDirectory *dir = get_filesystem_path(path);
+ if (dir) {
+ parent = dir;
+ break;
+ }
+ path = path.get_base_dir();
+ base--;
+ }
+
+ for (int i = base; i < max_bit; i++) {
+ EditorFileSystemDirectory *efd = memnew(EditorFileSystemDirectory);
+ efd->parent = parent;
+ efd->name = p_path.get_slice("/", i);
+ parent->subdirs.push_back(efd);
+
+ if (i == base) {
+ parent->subdirs.sort_custom<DirectoryComparator>();
+ }
+ parent = efd;
+ }
+}
+
ResourceUID::ID EditorFileSystem::_resource_saver_get_resource_id_for_path(const String &p_path, bool p_generate) {
if (!p_path.is_resource_file() || p_path.begins_with(ProjectSettings::get_singleton()->get_project_data_path())) {
// Saved externally (configuration file) or internal file, do not assign an ID.