diff --git a/crates/gpui/src/app/entity_map.rs b/crates/gpui/src/app/entity_map.rs index 07aa466295af2..8bf9c67269a19 100644 --- a/crates/gpui/src/app/entity_map.rs +++ b/crates/gpui/src/app/entity_map.rs @@ -117,8 +117,9 @@ impl EntityMap { pub fn read(&self, model: &Model) -> &T { self.assert_valid_context(model); - self.entities[model.entity_id] - .downcast_ref() + self.entities + .get(model.entity_id) + .and_then(|entity| entity.downcast_ref()) .unwrap_or_else(|| double_lease_panic::("read")) }