@@ -146,7 +146,7 @@ void ShaderEditorPlugin::edit(Object *p_object) {
146146			if  (edited_shaders[i].shader_inc .ptr () == shader_include) {
147147				shader_tabs->set_current_tab (i);
148148				shader_list->select (i);
149- 				_switch_to_editor (edited_shaders[i].shader_editor );
149+ 				_switch_to_editor (edited_shaders[i].shader_editor ,  true );
150150				return ;
151151			}
152152		}
@@ -162,7 +162,7 @@ void ShaderEditorPlugin::edit(Object *p_object) {
162162			if  (edited_shaders[i].shader .ptr () == shader) {
163163				shader_tabs->set_current_tab (i);
164164				shader_list->select (i);
165- 				_switch_to_editor (edited_shaders[i].shader_editor );
165+ 				_switch_to_editor (edited_shaders[i].shader_editor ,  true );
166166				return ;
167167			}
168168		}
@@ -778,7 +778,7 @@ void ShaderEditorPlugin::_update_shader_editor_zoom_factor(CodeTextEditor *p_sha
778778	}
779779}
780780
781- void  ShaderEditorPlugin::_switch_to_editor (ShaderEditor *p_editor) {
781+ void  ShaderEditorPlugin::_switch_to_editor (ShaderEditor *p_editor,  bool  p_focus ) {
782782	ERR_FAIL_NULL (p_editor);
783783	if  (file_menu->get_parent () != nullptr ) {
784784		file_menu->get_parent ()->remove_child (file_menu);
@@ -788,6 +788,12 @@ void ShaderEditorPlugin::_switch_to_editor(ShaderEditor *p_editor) {
788788	}
789789	empty_menu->set_visible (false );
790790	p_editor->use_menu_bar_items (file_menu, make_floating);
791+ 	if  (p_focus) {
792+ 		TextShaderEditor *text_shader_editor = Object::cast_to<TextShaderEditor>(p_editor);
793+ 		if  (text_shader_editor) {
794+ 			text_shader_editor->get_code_editor ()->get_text_editor ()->grab_focus ();
795+ 		}
796+ 	}
791797}
792798
793799void  ShaderEditorPlugin::_file_removed (const  String &p_removed_file) {
0 commit comments