### 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
if (input_action != INPUT_PASTE) {
		Transform3D xf;
		xf.basis.set_zero();
		RenderingServer::get_singleton()->instance_set_transform(paste_instance, xf);
		return;
	}
	Vector3 center = 0.5 * Vector3(real_t(node->get_center_x()), real_t(node->get_center_y()), real_t(node->get_center_z()));
	Vector3 scale = (Vector3(1, 1, 1) + (paste_indicator.end - paste_indicator.begin)) * node->get_cell_size();
	Transform3D xf;
	xf.scale(scale);
	xf.origin = (paste_indicator.begin + (paste_indicator.current - paste_indicator.click) + center) * node->get_cell_size();
	Basis rot;
	rot = node->get_basis_with_orthogonal_index(paste_indicator.orientation);
	xf.basis = rot * xf.basis;
	xf.translate_local((-center * node->get_cell_size()) / scale);
	RenderingServer::get_singleton()->instance_set_transform(paste_instance, node->get_global_transform() * xf);
	for (const ClipboardItem &item : clipboard_items) {
		xf = Transform3D();
		xf.origin = (paste_indicator.begin + (paste_indicator.current - paste_indicator.click) + center) * node->get_cell_size();
		xf.basis = rot * xf.basis;
		xf.translate_local(item.grid_offset * node->get_cell_size());
		Basis item_rot;
		item_rot = node->get_basis_with_orthogonal_index(item.orientation);
		xf.basis = item_rot * xf.basis * node->get_cell_scale();
		RenderingServer::get_singleton()->instance_set_transform(item.instance, node->get_global_transform() * xf);
	}
}
void GridMapEditor::_do_paste() {