### 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
scale[edit_axis] = 1.0;
			Vector3 position = selection.begin;
			position[edit_axis] = edit_floor[edit_axis];
			scale *= node->get_cell_size();
			position *= node->get_cell_size();
			Transform3D xf2;
			xf2.basis.scale(scale);
			xf2.origin = position;
			RenderingServer::get_singleton()->instance_set_transform(selection_level_instance[i], xf2);
		}
	}
}
void GridMapEditor::_validate_selection() {
	if (!selection.active) {
		return;
	}
	selection.begin = selection.click;
	selection.end = selection.current;
	if (selection.begin.x > selection.end.x) {
		SWAP(selection.begin.x, selection.end.x);
	}
	if (selection.begin.y > selection.end.y) {
		SWAP(selection.begin.y, selection.end.y);
	}
	if (selection.begin.z > selection.end.z) {
		SWAP(selection.begin.z, selection.end.z);
	}
	_update_selection_transform();
}
void GridMapEditor::_set_selection(bool p_active, const Vector3 &p_begin, const Vector3 &p_end) {