Repository: godotengine/godot
File: editor/gui/code_editor.cpp (C++)

Code before:

	float old_zoom_factor = zoom_factor;

	set_zoom_factor(p_zoom_factor);

	if (old_zoom_factor != zoom_factor) {
		emit_signal(SNAME("zoomed"), zoom_factor);
	}
}

void CodeTextEditor::set_zoom_factor(float p_zoom_factor) {
	zoom_factor = CLAMP(p_zoom_factor, 0.25f, 3.0f);
	int neutral_font_size = int(EDITOR_GET("interface/editor/code_font_size")) * EDSCALE;
	int new_font_size = Math::round(zoom_factor * neutral_font_size);

	zoom_button->set_text(itos(Math::round(zoom_factor * 100)) + " %");

	text_editor->add_theme_font_size_override(SceneStringName(font_size), new_font_size);
}

float CodeTextEditor::get_zoom_factor() {
	return zoom_factor;
}

void CodeTextEditor::_show_goto_popup_request() {
	line_and_col_button->release_focus();
	emit_signal("show_goto_popup");
}

void CodeTextEditor::_bind_methods() {
	ADD_SIGNAL(MethodInfo("validate_script"));
	ADD_SIGNAL(MethodInfo("load_theme_settings"));
	ADD_SIGNAL(MethodInfo("show_errors_panel"));
	ADD_SIGNAL(MethodInfo("show_warnings_panel"));
	ADD_SIGNAL(MethodInfo("show_goto_popup"));
	ADD_SIGNAL(MethodInfo("navigation_preview_ended"));
	ADD_SIGNAL(MethodInfo("zoomed", PropertyInfo(Variant::FLOAT, "p_zoom_factor")));
}

void CodeTextEditor::set_code_complete_func(CodeTextEditorCodeCompleteFunc p_code_complete_func, void *p_ud) {
	code_complete_func = p_code_complete_func;
	code_complete_ud = p_ud;
}

void CodeTextEditor::set_toggle_list_control(Control *p_toggle_list_control) {
	toggle_files_list = p_toggle_list_control;
}

void CodeTextEditor::show_toggle_files_button() {
	toggle_files_button->show();
}

Review comment (suggestion):
This prevents the button from taking focus back, but the TextEdit still doesn't get focus when the go to line popup closes.

I think GotoLinePopup should give focus to the TextEdit when it closes. Like:
```diff
diff --git a/editor/gui/code_editor.cpp b/editor/gui/code_editor.cpp
index e56bd0a04c..22ac9bec64 100644
--- a/editor/gui/code_editor.cpp
+++ b/editor/gui/code_editor.cpp
@@ -95,6 +95,7 @@ void GotoLinePopup::_notification(int p_what) {
 		case NOTIFICATION_VISIBILITY_CHANGED: {
 			if (!is_visible()) {
 				text_editor->set_preview_navigation_change(false);
+				text_editor->get_text_editor()->grab_focus();
 			}
 		} break;
 	}

```

Code after:
	}

	float old_zoom_factor = zoom_factor;

	set_zoom_factor(p_zoom_factor);

	if (old_zoom_factor != zoom_factor) {
		emit_signal(SNAME("zoomed"), zoom_factor);
	}
}

void CodeTextEditor::set_zoom_factor(float p_zoom_factor) {
	zoom_factor = CLAMP(p_zoom_factor, 0.25f, 3.0f);
	int neutral_font_size = int(EDITOR_GET("interface/editor/code_font_size")) * EDSCALE;
	int new_font_size = Math::round(zoom_factor * neutral_font_size);

	zoom_button->set_text(itos(Math::round(zoom_factor * 100)) + " %");

	text_editor->add_theme_font_size_override(SceneStringName(font_size), new_font_size);
}

float CodeTextEditor::get_zoom_factor() {
	return zoom_factor;
}

void CodeTextEditor::_show_goto_popup_request() {
	emit_signal("show_goto_popup");
}

void CodeTextEditor::_bind_methods() {
	ADD_SIGNAL(MethodInfo("validate_script"));
	ADD_SIGNAL(MethodInfo("load_theme_settings"));
	ADD_SIGNAL(MethodInfo("show_errors_panel"));
	ADD_SIGNAL(MethodInfo("show_warnings_panel"));
	ADD_SIGNAL(MethodInfo("show_goto_popup"));
	ADD_SIGNAL(MethodInfo("navigation_preview_ended"));
	ADD_SIGNAL(MethodInfo("zoomed", PropertyInfo(Variant::FLOAT, "p_zoom_factor")));
}

void CodeTextEditor::set_code_complete_func(CodeTextEditorCodeCompleteFunc p_code_complete_func, void *p_ud) {
	code_complete_func = p_code_complete_func;
	code_complete_ud = p_ud;
}

void CodeTextEditor::set_toggle_list_control(Control *p_toggle_list_control) {
	toggle_files_list = p_toggle_list_control;
}

void CodeTextEditor::show_toggle_files_button() {
	toggle_files_button->show();
}