Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Don't scroll to selected file in FileSystem when saving scenes #101078

Merged
merged 1 commit into from
Jan 6, 2025
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 8 additions & 9 deletions editor/filesystem_dock.cpp
Original file line number Diff line number Diff line change
@@ -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()) {
2 changes: 1 addition & 1 deletion editor/filesystem_dock.h
Original file line number Diff line number Diff line change
@@ -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);