From 77091f5e67797f4c795fbb4f84fcb948762537fa Mon Sep 17 00:00:00 2001 From: tle-oops <7878845+toanle31@users.noreply.github.com> Date: Thu, 23 Oct 2025 09:23:13 -0400 Subject: [PATCH] Allow FileSystemDock to navigate to currently selected scene tab as an option --- doc/classes/EditorSettings.xml | 3 +++ editor/editor_node.cpp | 13 +++++++++++++ editor/editor_node.h | 3 +++ editor/settings/editor_settings.cpp | 1 + 4 files changed, 20 insertions(+) diff --git a/doc/classes/EditorSettings.xml b/doc/classes/EditorSettings.xml index f11bd0f0202..d1effc152e6 100644 --- a/doc/classes/EditorSettings.xml +++ b/doc/classes/EditorSettings.xml @@ -1060,6 +1060,9 @@ If [code]true[/code], the floating panel position, size, and screen will be saved on editor exit. On next launch the panels that were floating will be made floating in the saved positions, sizes and screens, if possible. + + If [code]true[/code], the FileSystem dock will automatically navigate to the currently selected scene tab. + Controls when the Close (X) button is displayed on scene tabs at the top of the editor. diff --git a/editor/editor_node.cpp b/editor/editor_node.cpp index e268872beb8..f07870adbbd 100644 --- a/editor/editor_node.cpp +++ b/editor/editor_node.cpp @@ -4307,10 +4307,23 @@ void EditorNode::_set_current_scene_nocheck(int p_idx) { callable_mp(this, &EditorNode::_set_main_scene_state).call_deferred(state, get_edited_scene()); // Do after everything else is done setting up. } + if (!select_current_scene_file_requested && EDITOR_GET("interface/scene_tabs/auto_select_current_scene_file")) { + select_current_scene_file_requested = true; + callable_mp(this, &EditorNode::_nav_to_selected_scene).call_deferred(); + } + _update_undo_redo_allowed(); _update_unsaved_cache(); } +void EditorNode::_nav_to_selected_scene() { + select_current_scene_file_requested = false; + const String scene_path = editor_data.get_scene_path(scene_tabs->get_current_tab()); + if (!scene_path.is_empty()) { + FileSystemDock::get_singleton()->navigate_to_path(scene_path); + } +} + void EditorNode::setup_color_picker(ColorPicker *p_picker) { p_picker->set_editor_settings(EditorSettings::get_singleton()); int default_color_mode = EditorSettings::get_singleton()->get_project_metadata("color_picker", "color_mode", EDITOR_GET("interface/inspector/default_color_picker_mode")); diff --git a/editor/editor_node.h b/editor/editor_node.h index a44975d417d..ea77afe16db 100644 --- a/editor/editor_node.h +++ b/editor/editor_node.h @@ -454,6 +454,8 @@ private: bool waiting_for_first_scan = true; bool load_editor_layout_done = false; + bool select_current_scene_file_requested = false; + HashSet> tracked_translations; bool pending_translation_notification = false; @@ -586,6 +588,7 @@ private: void _set_current_scene(int p_idx); void _set_current_scene_nocheck(int p_idx); + void _nav_to_selected_scene(); bool _validate_scene_recursive(const String &p_filename, Node *p_node); void _save_scene(String p_file, int idx = -1); void _save_all_scenes(); diff --git a/editor/settings/editor_settings.cpp b/editor/settings/editor_settings.cpp index 1ac5e4ca4d1..a5be8b6b4e9 100644 --- a/editor/settings/editor_settings.cpp +++ b/editor/settings/editor_settings.cpp @@ -619,6 +619,7 @@ void EditorSettings::_load_defaults(Ref p_extra_config) { EDITOR_SETTING_USAGE(Variant::INT, PROPERTY_HINT_RANGE, "interface/scene_tabs/maximum_width", 350, "0,9999,1", PROPERTY_USAGE_DEFAULT) _initial_set("interface/scene_tabs/show_script_button", false, true); _initial_set("interface/scene_tabs/restore_scenes_on_load", true, true); + EDITOR_SETTING_BASIC(Variant::BOOL, PROPERTY_HINT_NONE, "interface/scene_tabs/auto_select_current_scene_file", false, ""); // Multi Window EDITOR_SETTING_BASIC(Variant::BOOL, PROPERTY_HINT_NONE, "interface/multi_window/enable", true, "");