From e492ddde127297af363f58235309f477efe49b9e Mon Sep 17 00:00:00 2001 From: Lars Pettersson Date: Fri, 3 Jan 2025 16:29:00 +0100 Subject: [PATCH] Don't scroll to selected file in FileSystem when saving scenes --- editor/filesystem_dock.cpp | 17 ++++++++--------- editor/filesystem_dock.h | 2 +- 2 files changed, 9 insertions(+), 10 deletions(-) diff --git a/editor/filesystem_dock.cpp b/editor/filesystem_dock.cpp index 6b6abd47620..2502a0e50a9 100644 --- a/editor/filesystem_dock.cpp +++ b/editor/filesystem_dock.cpp @@ -367,7 +367,7 @@ Vector FileSystemDock::get_uncollapsed_paths() const { return uncollapsed_paths; } -void FileSystemDock::_update_tree(const Vector &p_uncollapsed_paths, bool p_uncollapse_root, bool p_select_in_favorites, bool p_unfold_path) { +void FileSystemDock::_update_tree(const Vector &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 &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 &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 da47bc9abf8..eba64a4fc61 100644 --- a/editor/filesystem_dock.h +++ b/editor/filesystem_dock.h @@ -249,7 +249,7 @@ private: Ref _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 &uncollapsed_paths, bool p_select_in_favorites, bool p_unfold_path = false); - void _update_tree(const Vector &p_uncollapsed_paths = Vector(), bool p_uncollapse_root = false, bool p_select_in_favorites = false, bool p_unfold_path = false); + void _update_tree(const Vector &p_uncollapsed_paths = Vector(), 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);