diff --git a/crates/gpui2/src/key_dispatch.rs b/crates/gpui2/src/key_dispatch.rs index 7b8d506d03b2feb5c349838625a51e9d2d27b4b7..1e08c11a52b353048d8110f420d426426041060b 100644 --- a/crates/gpui2/src/key_dispatch.rs +++ b/crates/gpui2/src/key_dispatch.rs @@ -149,13 +149,19 @@ impl DispatchTree { } pub fn available_actions(&self, target: DispatchNodeId) -> Vec> { - let mut actions = Vec::new(); + let mut actions = Vec::>::new(); for node_id in self.dispatch_path(target) { let node = &self.nodes[node_id.0]; for DispatchActionListener { action_type, .. } in &node.action_listeners { - // Intentionally silence these errors without logging. - // If an action cannot be built by default, it's not available. - actions.extend(self.action_registry.build_action_type(action_type).ok()); + if let Err(ix) = actions.binary_search_by_key(action_type, |a| a.as_any().type_id()) + { + // Intentionally silence these errors without logging. + // If an action cannot be built by default, it's not available. + let action = self.action_registry.build_action_type(action_type).ok(); + if let Some(action) = action { + actions.insert(ix, action); + } + } } } actions