Repository: godotengine/godot (language: cpp)

Issue:
The file system dock scrolls automatically when saving a scene.
### Tested versions

v4.4.dev7.official [46c8f8c5c]
v3.6.stable.official [de2f0f147]

### System information

w10 64

### Issue description

Observe the file system dock in the attached video.
When I save a scene or perform the save action, the dock scrolls automatically to the selected scene without any reason.

https://github.com/user-attachments/assets/be038359-8cb8-4ef4-9bbc-754715cbb46c


### Steps to reproduce

To reproduce, please watch the video.

### Minimal reproduction project (MRP)

...


Discussion / hints:

I thought it was a bug. What is the reason this should happen if it's not a bug?
That's what's to discuss, I don't know what the cause of this is and it could be intentional 
Ok, just to emphasize that the scene the dock scrolls to has no relation to the scene being saved.

Fix patch:
diff --git a/editor/filesystem_dock.cpp b/editor/filesystem_dock.cpp
index 6b6abd476205..2502a0e50a9b 100644
--- a/editor/filesystem_dock.cpp
+++ b/editor/filesystem_dock.cpp
@@ -367,7 +367,7 @@ Vector<String> FileSystemDock::get_uncollapsed_paths() const {
 	return uncollapsed_paths;
 }
 
-void FileSystemDock::_update_tree(const Vector<String> &p_uncollapsed_paths, bool p_uncollapse_root, bool p_select_in_favorites, bool p_unfold_path) {
+void FileSystemDock::_update_tree(const Vector<String> &p_uncollapsed_paths, bool p_uncollapse_root, bool p_scroll_to_selected) {
 	// Recreate the tree.
 	tree->clear();
 	tree_update_id++;
@@ -436,10 +436,7 @@ void FileSystemDock::_update_tree(const Vector<String> &p_uncollapsed_paths, boo
 		ti->set_tooltip_text(0, favorite);
 		ti->set_selectable(0, true);
 		ti->set_metadata(0, favorite);
-		if (p_select_in_favorites && favorite == current_path) {
-			ti->select(0);
-			ti->set_as_cursor(0);
-		}
+
 		if (!favorite.ends_with("/")) {
 			Array udata;
 			udata.push_back(tree_update_id);
@@ -454,12 +451,15 @@ void FileSystemDock::_update_tree(const Vector<String> &p_uncollapsed_paths, boo
 	}
 
 	// Create the remaining of the tree.
-	_create_tree(root, EditorFileSystem::get_singleton()->get_filesystem(), uncollapsed_paths, p_select_in_favorites, p_unfold_path);
+	_create_tree(root, EditorFileSystem::get_singleton()->get_filesystem(), uncollapsed_paths, false);
 	if (!searched_tokens.is_empty()) {
 		_update_filtered_items();
 	}
 
-	tree->ensure_cursor_is_visible();
+	if (p_scroll_to_selected) {
+		tree->ensure_cursor_is_visible();
+	}
+
 	updating_tree = false;
 }
 
@@ -1375,7 +1375,6 @@ void FileSystemDock::_update_history() {
 	if (tree->is_visible()) {
 		_update_tree(get_uncollapsed_paths());
 		tree->grab_focus();
-		tree->ensure_cursor_is_visible();
 	}
 
 	if (file_list_vb->is_visible()) {
@@ -2717,7 +2716,7 @@ void FileSystemDock::fix_dependencies(const String &p_for_file) {
 
 void FileSystemDock::update_all() {
 	if (tree->is_visible()) {
-		_update_tree(get_uncollapsed_paths());
+		_update_tree(get_uncollapsed_paths(), false, false);
 	}
 
 	if (file_list_vb->is_visible()) {
diff --git a/editor/filesystem_dock.h b/editor/filesystem_dock.h
index da47bc9abf8c..eba64a4fc61b 100644
--- a/editor/filesystem_dock.h
+++ b/editor/filesystem_dock.h
@@ -249,7 +249,7 @@ class FileSystemDock : public VBoxContainer {
 
 	Ref<Texture2D> _get_tree_item_icon(bool p_is_valid, const String &p_file_type, const String &p_icon_path);
 	void _create_tree(TreeItem *p_parent, EditorFileSystemDirectory *p_dir, Vector<String> &uncollapsed_paths, bool p_select_in_favorites, bool p_unfold_path = false);
-	void _update_tree(const Vector<String> &p_uncollapsed_paths = Vector<String>(), bool p_uncollapse_root = false, bool p_select_in_favorites = false, bool p_unfold_path = false);
+	void _update_tree(const Vector<String> &p_uncollapsed_paths = Vector<String>(), bool p_uncollapse_root = false, bool p_scroll_to_selected = true);
 	void _navigate_to_path(const String &p_path, bool p_select_in_favorites = false);
 	bool _update_filtered_items(TreeItem *p_tree_item = nullptr);
 


Test patch: