### Godot version

4.0 Beta 10

### System information

Windows 10

### Issue description

when picking tiles from a gridmap and you have a search filter applied, it often doesn't do anything, instead I get an index out of bounds error in the console
`scene/gui/item_list.cpp:424 - Index p_current = 8 is out of bounds (items.size() = 4).`

### Steps to reproduce

1. Open a project using a gridmap like the platformer demo, or create one.
2. Search for specific tiles inside the tile selection.
3. Try to pick a tile inside the 3D viewport with that you want to paint (maybe you don't want to reset the filter and do a long search there)

In some cases it works, but mostly it doesn't work (depending on the tile you picked and what you searched for)
Also I am not sure, but I have the feeling that in a few cases it picks the wrong tile, instead of throwing an error

### Minimal reproduction project

Any project that uses a gridmap, for example the platformer demo from the demo projects repo
}
	Camera3D *camera = p_camera;
	Vector3 from = camera->project_ray_origin(p_point);
	Vector3 normal = camera->project_ray_normal(p_point);
	Transform3D local_xform = node->get_global_transform().affine_inverse();
	Vector<Plane> planes = camera->get_frustum();
	from = local_xform.xform(from);
	normal = local_xform.basis.xform(normal).normalized();
	Plane p;
	p.normal[edit_axis] = 1.0;
	p.d = edit_floor[edit_axis] * node->get_cell_size()[edit_axis];
	Vector3 inters;
	if (!p.intersects_segment(from, from + normal * settings_pick_distance->get_value(), &inters)) {
		return false;
	}
	
	
	for (int i = 0; i < planes.size(); i++) {
		Plane fp = local_xform.xform(planes[i]);
		if (fp.is_point_over(inters)) {
			return false;
		}
	}
	int cell[3];
	Vector3 cell_size = node->get_cell_size();
	for (int i = 0; i < 3; i++) {
		if (i == edit_axis) {
			cell[i] = edit_floor[i];
		} else {
			cell[i] = inters[i] / cell_size[i];