Use the same InlineAssist action between both assistant and assistant2 (#22126)

This PR makes it so `assistant` and `assistant2` both use the same
action for inline assist (`zed_actions::InlineAssist`).

This makes it so the keybindings to deploy the inline assist seamlessly
swap based on the feature flag without needing to rebind them.

One minor caveat: if you're using `assistant2` the action name in the
command palette will be `assistant: inline assist`.

Release Notes:

- N/A
This commit is contained in:
Marshall Bowers 2024-12-16 23:57:07 -05:00 committed by GitHub
parent 80431e5518
commit 3052fc2565
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
5 changed files with 29 additions and 11 deletions

View file

@ -19,6 +19,9 @@ pub fn init(cx: &mut AppContext) {
pub struct CommandPaletteFilter {
hidden_namespaces: HashSet<&'static str>,
hidden_action_types: HashSet<TypeId>,
/// Actions that have explicitly been shown. These should be shown even if
/// they are in a hidden namespace.
shown_action_types: HashSet<TypeId>,
}
#[derive(Deref, DerefMut, Default)]
@ -53,6 +56,11 @@ impl CommandPaletteFilter {
let name = action.name();
let namespace = name.split("::").next().unwrap_or("malformed action name");
// If this action has specifically been shown then it should be visible.
if self.shown_action_types.contains(&action.type_id()) {
return false;
}
self.hidden_namespaces.contains(namespace)
|| self.hidden_action_types.contains(&action.type_id())
}
@ -69,12 +77,16 @@ impl CommandPaletteFilter {
/// Hides all actions with the given types.
pub fn hide_action_types(&mut self, action_types: &[TypeId]) {
self.hidden_action_types.extend(action_types);
for action_type in action_types {
self.hidden_action_types.insert(*action_type);
self.shown_action_types.remove(action_type);
}
}
/// Shows all actions with the given types.
pub fn show_action_types<'a>(&mut self, action_types: impl Iterator<Item = &'a TypeId>) {
for action_type in action_types {
self.shown_action_types.insert(*action_type);
self.hidden_action_types.remove(action_type);
}
}