Browse Source

Re-grab FileSystem focus after rescan

kobewi 5 months ago
parent
commit
9dcf720f50
2 changed files with 11 additions and 0 deletions
  1. 10 0
      editor/filesystem_dock.cpp
  2. 1 0
      editor/filesystem_dock.h

+ 10 - 0
editor/filesystem_dock.cpp

@@ -1338,6 +1338,10 @@ void FileSystemDock::_fs_changed() {
 	}
 	}
 
 
 	set_process(false);
 	set_process(false);
+	if (had_focus) {
+		had_focus->grab_focus();
+		had_focus = nullptr;
+	}
 }
 }
 
 
 void FileSystemDock::_set_scanning_mode() {
 void FileSystemDock::_set_scanning_mode() {
@@ -2675,6 +2679,12 @@ bool FileSystemDock::_matches_all_search_tokens(const String &p_text) {
 }
 }
 
 
 void FileSystemDock::_rescan() {
 void FileSystemDock::_rescan() {
+	if (tree->has_focus()) {
+		had_focus = tree;
+	} else if (files->has_focus()) {
+		had_focus = files;
+	}
+
 	_set_scanning_mode();
 	_set_scanning_mode();
 	EditorFileSystem::get_singleton()->scan();
 	EditorFileSystem::get_singleton()->scan();
 }
 }

+ 1 - 0
editor/filesystem_dock.h

@@ -235,6 +235,7 @@ private:
 	bool import_dock_needs_update = false;
 	bool import_dock_needs_update = false;
 	TreeItem *resources_item = nullptr;
 	TreeItem *resources_item = nullptr;
 	TreeItem *favorites_item = nullptr;
 	TreeItem *favorites_item = nullptr;
+	Control *had_focus = nullptr;
 
 
 	bool holding_branch = false;
 	bool holding_branch = false;
 	Vector<TreeItem *> tree_items_selected_on_drag_begin;
 	Vector<TreeItem *> tree_items_selected_on_drag_begin;