File tree Expand file tree Collapse file tree 4 files changed +29
-2
lines changed
Expand file tree Collapse file tree 4 files changed +29
-2
lines changed Original file line number Diff line number Diff line change 3030
3131#include " editor_file_dialog.h"
3232
33+ #include " core/config/project_settings.h"
3334#include " editor/docks/filesystem_dock.h"
3435#include " editor/file_system/dependency_editor.h"
3536#include " editor/settings/editor_settings.h"
@@ -92,6 +93,26 @@ void EditorFileDialog::_validate_property(PropertyInfo &p_property) const {
9293 }
9394}
9495
96+ void EditorFileDialog::_dir_contents_changed () {
97+ bool scan_required = false ;
98+ switch (get_access ()) {
99+ case FileDialog::ACCESS_RESOURCES: {
100+ scan_required = true ;
101+ } break ;
102+ case FileDialog::ACCESS_USERDATA: {
103+ // Directories within the project dir are unlikely to be accessed.
104+ } break ;
105+ case FileDialog::ACCESS_FILESYSTEM: {
106+ // Directories within the project dir may still be accessed.
107+ const String localized_path = ProjectSettings::get_singleton ()->localize_path (get_current_dir ());
108+ scan_required = localized_path.is_resource_file ();
109+ } break ;
110+ }
111+ if (scan_required) {
112+ EditorFileSystem::get_singleton ()->scan_changes ();
113+ }
114+ }
115+
95116void EditorFileDialog::_notification (int p_what) {
96117 switch (p_what) {
97118 case NOTIFICATION_VISIBILITY_CHANGED: {
Original file line number Diff line number Diff line change @@ -41,6 +41,7 @@ class EditorFileDialog : public FileDialog {
4141
4242protected:
4343 virtual void _item_menu_id_pressed (int p_option) override ;
44+ virtual void _dir_contents_changed () override ;
4445
4546 virtual bool _should_use_native_popup () const override ;
4647 virtual bool _should_hide_file (const String &p_file) const override ;
Original file line number Diff line number Diff line change @@ -1064,8 +1064,11 @@ void FileDialog::_file_list_select_first() {
10641064}
10651065
10661066void FileDialog::_delete_confirm () {
1067- OS::get_singleton ()->move_to_trash (_get_item_path (_get_selected_file_idx ()));
1068- invalidate ();
1067+ Error err = OS::get_singleton ()->move_to_trash (_get_item_path (_get_selected_file_idx ()));
1068+ if (err == OK) {
1069+ invalidate ();
1070+ _dir_contents_changed ();
1071+ }
10691072}
10701073
10711074void FileDialog::_filename_filter_selected () {
@@ -1537,6 +1540,7 @@ FileDialog::Access FileDialog::get_access() const {
15371540void FileDialog::_make_dir_confirm () {
15381541 Error err = dir_access->make_dir (new_dir_name->get_text ().strip_edges ());
15391542 if (err == OK) {
1543+ _dir_contents_changed ();
15401544 _change_dir (new_dir_name->get_text ().strip_edges ());
15411545 update_filters ();
15421546 _push_history ();
Original file line number Diff line number Diff line change @@ -368,6 +368,7 @@ class FileDialog : public ConfirmationDialog {
368368
369369 bool _can_use_native_popup () const ;
370370 virtual void _item_menu_id_pressed (int p_option);
371+ virtual void _dir_contents_changed () {}
371372
372373 virtual bool _should_use_native_popup () const ;
373374 virtual bool _should_hide_file (const String &p_file) const { return false ; }
You can’t perform that action at this time.
0 commit comments