Skip to content
Open
Show file tree
Hide file tree
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
62 changes: 19 additions & 43 deletions editor/script/script_editor_plugin.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -738,25 +738,26 @@ void ScriptEditor::_go_to_tab(int p_idx) {

c = tab_container->get_current_tab_control();

if (Object::cast_to<ScriptEditorBase>(c)) {
script_name_label->set_text(Object::cast_to<ScriptEditorBase>(c)->get_name());
script_icon->set_texture(Object::cast_to<ScriptEditorBase>(c)->get_theme_icon());
ScriptEditorBase *seb = Object::cast_to<ScriptEditorBase>(c);
if (seb) {
if (is_visible_in_tree()) {
Object::cast_to<ScriptEditorBase>(c)->ensure_focus();
seb->ensure_focus();
}

Ref<Script> scr = Object::cast_to<ScriptEditorBase>(c)->get_edited_resource();
Ref<Script> scr = seb->get_edited_resource();
if (scr.is_valid()) {
notify_script_changed(scr);
}

Object::cast_to<ScriptEditorBase>(c)->validate();
seb->validate();
}
if (Object::cast_to<EditorHelp>(c)) {
script_name_label->set_text(Object::cast_to<EditorHelp>(c)->get_class());
script_icon->set_texture(get_editor_theme_icon(SNAME("Help")));

EditorHelp *eh = Object::cast_to<EditorHelp>(c);
if (eh) {
script_name_label->set_text(eh->get_class());

if (is_visible_in_tree()) {
Object::cast_to<EditorHelp>(c)->set_focused();
eh->set_focused();
}
}

Expand Down Expand Up @@ -1838,8 +1839,6 @@ void ScriptEditor::_notification(int p_what) {
filter_scripts->set_right_icon(get_editor_theme_icon(SNAME("Search")));
filter_methods->set_right_icon(get_editor_theme_icon(SNAME("Search")));

filename->add_theme_style_override(CoreStringName(normal), get_theme_stylebox(CoreStringName(normal), SNAME("LineEdit")));

recent_scripts->reset_size();

if (is_inside_tree()) {
Expand Down Expand Up @@ -2015,6 +2014,7 @@ void ScriptEditor::_script_selected(int p_idx) {
grab_focus_block = !Input::get_singleton()->is_mouse_button_pressed(MouseButton::LEFT); //amazing hack, simply amazing

_go_to_tab(script_list->get_item_metadata(p_idx));
script_name_label->set_text(script_list->get_item_text(p_idx));
Comment on lines 2016 to +2017
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟡 Minor

Keep script_name_label driven by the current-tab refresh path.

Line 2017 only updates the header for list-click selection. With the old centralized filename updates removed, the label can now drift stale in states that don't pass through _script_selected()—most visibly after the last tab is closed, since _update_script_names() rebuilds the list but never clears the label when it becomes empty. I'd keep this label update centralized in the same path that handles current-tab changes and explicitly reset it when no tab is selected.

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@editor/script/script_editor_plugin.cpp` around lines 2016 - 2017, Move the
script_name_label update out of the list-click path and into the centralized
current-tab refresh flow: remove the set_text call after _go_to_tab and instead
update script_name_label inside the same code that handles current-tab changes
(e.g., _script_selected or the function that _go_to_tab ultimately triggers),
using script_list->get_item_text(p_idx) when a tab is selected and explicitly
clear script_name_label (set to empty) when no tab is selected (e.g., after
_update_script_names rebuilds the list and selection is invalid); ensure any
metadata-driven behavior still uses script_list->get_item_metadata(p_idx) as
before.

grab_focus_block = false;
}

Expand Down Expand Up @@ -2147,11 +2147,6 @@ void ScriptEditor::_update_members_overview() {
members_overview->set_item_metadata(-1, line);
}
}

String path = se->get_edited_resource()->get_path();
bool built_in = !path.is_resource_file();
String name = built_in ? path.get_file() : se->get_name();
filename->set_text(name);
}

void ScriptEditor::_update_help_overview_visibility() {
Expand All @@ -2173,7 +2168,6 @@ void ScriptEditor::_update_help_overview_visibility() {
filter_methods->set_visible(false);
help_overview->set_visible(true);
overview_vbox->set_visible(true);
filename->set_text(se->get_name());
} else {
help_overview->set_visible(false);
overview_vbox->set_visible(false);
Expand Down Expand Up @@ -2446,7 +2440,6 @@ void ScriptEditor::_update_script_names() {
script_list->select(index);

script_name_label->set_text(sedata_filtered[i].name);
script_icon->set_texture(sedata_filtered[i].icon);

ScriptEditorBase *se = _get_current_editor();
if (se) {
Expand Down Expand Up @@ -4275,14 +4268,13 @@ ScriptEditor::ScriptEditor(WindowWrapper *p_wrapper) {
buttons_hbox = memnew(HBoxContainer);
overview_vbox->add_child(buttons_hbox);

filename = memnew(Label);
filename->set_focus_mode(FOCUS_ACCESSIBILITY);
filename->set_auto_translate_mode(AUTO_TRANSLATE_MODE_DISABLED);
filename->set_clip_text(true);
filename->set_h_size_flags(SIZE_EXPAND_FILL);
filename->set_vertical_alignment(VERTICAL_ALIGNMENT_CENTER);
filename->add_theme_style_override(CoreStringName(normal), EditorNode::get_singleton()->get_editor_theme()->get_stylebox(CoreStringName(normal), SNAME("LineEdit")));
buttons_hbox->add_child(filename);
filter_methods = memnew(LineEdit);
filter_methods->set_placeholder(TTRC("Filter Methods"));
filter_methods->set_accessibility_name(TTRC("Filter Methods"));
filter_methods->set_clear_button_enabled(true);
filter_methods->set_h_size_flags(SIZE_EXPAND_FILL);
filter_methods->connect(SceneStringName(text_changed), callable_mp(this, &ScriptEditor::_filter_methods_text_changed));
buttons_hbox->add_child(filter_methods);

members_overview_alphabeta_sort_button = memnew(Button);
members_overview_alphabeta_sort_button->set_theme_type_variation(SceneStringName(FlatButton));
Expand All @@ -4293,13 +4285,6 @@ ScriptEditor::ScriptEditor(WindowWrapper *p_wrapper) {

buttons_hbox->add_child(members_overview_alphabeta_sort_button);

filter_methods = memnew(LineEdit);
filter_methods->set_placeholder(TTRC("Filter Methods"));
filter_methods->set_accessibility_name(TTRC("Filter Methods"));
filter_methods->set_clear_button_enabled(true);
filter_methods->connect(SceneStringName(text_changed), callable_mp(this, &ScriptEditor::_filter_methods_text_changed));
overview_vbox->add_child(filter_methods);

members_overview = memnew(ItemList);
members_overview->set_auto_translate_mode(AUTO_TRANSLATE_MODE_DISABLED);
members_overview->set_theme_type_variation("ItemListSecondary");
Expand Down Expand Up @@ -4435,19 +4420,10 @@ ScriptEditor::ScriptEditor(WindowWrapper *p_wrapper) {
debugger->connect("breakpoint_set_in_tree", callable_mp(this, &ScriptEditor::_set_breakpoint));
debugger->connect("breakpoints_cleared_in_tree", callable_mp(this, &ScriptEditor::_clear_breakpoints));

menu_hb->add_spacer();

script_icon = memnew(TextureRect);
menu_hb->add_child(script_icon);
script_name_label = memnew(Label);
script_name_label->set_focus_mode(FOCUS_ACCESSIBILITY);
menu_hb->add_child(script_name_label);

script_icon->hide();
script_name_label->hide();

menu_hb->add_spacer();

site_search = memnew(Button);
site_search->set_theme_type_variation(SceneStringName(FlatButton));
site_search->set_accessibility_name(TTRC("Site Search"));
Expand Down
2 changes: 0 additions & 2 deletions editor/script/script_editor_plugin.h
Original file line number Diff line number Diff line change
Expand Up @@ -348,7 +348,6 @@ class ScriptEditor : public PanelContainer {
VBoxContainer *scripts_vbox = nullptr;
VBoxContainer *overview_vbox = nullptr;
HBoxContainer *buttons_hbox = nullptr;
Label *filename = nullptr;
Button *members_overview_alphabeta_sort_button = nullptr;
bool members_overview_enabled;
ItemList *help_overview = nullptr;
Expand All @@ -364,7 +363,6 @@ class ScriptEditor : public PanelContainer {

float zoom_factor = 1.0f;

TextureRect *script_icon = nullptr;
Label *script_name_label = nullptr;

Button *script_back = nullptr;
Expand Down
Loading