### Godot version

v4.1.1-stable_mono_win64

### System information

Windows 11

### Issue description

I removed the node to replace it with another, but when I change the path in the code, the engine crashes for me.

### Steps to reproduce

I did a screen recording as it happens:

https://github.com/godotengine/godot/assets/116289408/b2fd2689-8d82-44e8-8e02-be01674842e1



### Minimal reproduction project

[MixApo.zip](https://github.com/godotengine/godot/files/12208403/MixApo.zip)

return (code_completion_active) ? code_completion_current_selected : -1;
}
void CodeEdit::set_code_completion_selected_index(int p_index) {
	if (!code_completion_active) {
		return;
	}
	ERR_FAIL_INDEX(p_index, code_completion_options.size());
	code_completion_current_selected = p_index;
	code_completion_force_item_center = -1;
	queue_redraw();
}
void CodeEdit::confirm_code_completion(bool p_replace) {
	if (!is_editable() || !code_completion_active) {
		return;
	}
	if (GDVIRTUAL_CALL(_confirm_code_completion, p_replace)) {
		return;
	}
	char32_t caret_last_completion_char = 0;
	begin_complex_operation();
	Vector<int> caret_edit_order = get_caret_index_edit_order();
	for (const int &i : caret_edit_order) {
		int caret_line = get_caret_line(i);
		const String &insert_text = code_completion_options[code_completion_current_selected].insert_text;
		const String &display_text = code_completion_options[code_completion_current_selected].display;
		if (p_replace) {