Encapsulate CommandPaletteFilter
and CommandPaletteInterceptor
(#9402)
This PR refactors the `CommandPaletteFilter` and `CommandPaletteInterceptor` to better encapsulate their internals. Previously these globals and their fields were publicly accessible, which meant that there was a lot of reaching in and making modifications. These changes should make it easier to add additional consumers of these hooks (right now they're primarily used by Vim mode). Release Notes: - N/A
This commit is contained in:
parent
d311a4b840
commit
55f4c8e51b
6 changed files with 164 additions and 56 deletions
|
@ -66,33 +66,26 @@ pub fn init(
|
|||
let copilot_auth_action_types = [TypeId::of::<SignOut>()];
|
||||
let copilot_no_auth_action_types = [TypeId::of::<SignIn>()];
|
||||
let status = handle.read(cx).status();
|
||||
let filter = cx.default_global::<CommandPaletteFilter>();
|
||||
let filter = CommandPaletteFilter::global_mut(cx);
|
||||
|
||||
match status {
|
||||
Status::Disabled => {
|
||||
filter.hidden_action_types.extend(copilot_action_types);
|
||||
filter.hidden_action_types.extend(copilot_auth_action_types);
|
||||
filter
|
||||
.hidden_action_types
|
||||
.extend(copilot_no_auth_action_types);
|
||||
filter.hide_action_types(&copilot_action_types);
|
||||
filter.hide_action_types(&copilot_auth_action_types);
|
||||
filter.hide_action_types(&copilot_no_auth_action_types);
|
||||
}
|
||||
Status::Authorized => {
|
||||
filter
|
||||
.hidden_action_types
|
||||
.extend(copilot_no_auth_action_types);
|
||||
for type_id in copilot_action_types
|
||||
.iter()
|
||||
.chain(&copilot_auth_action_types)
|
||||
{
|
||||
filter.hidden_action_types.remove(type_id);
|
||||
}
|
||||
filter.hide_action_types(&copilot_no_auth_action_types);
|
||||
filter.show_action_types(
|
||||
copilot_action_types
|
||||
.iter()
|
||||
.chain(&copilot_auth_action_types),
|
||||
);
|
||||
}
|
||||
_ => {
|
||||
filter.hidden_action_types.extend(copilot_action_types);
|
||||
filter.hidden_action_types.extend(copilot_auth_action_types);
|
||||
for type_id in &copilot_no_auth_action_types {
|
||||
filter.hidden_action_types.remove(type_id);
|
||||
}
|
||||
filter.hide_action_types(&copilot_action_types);
|
||||
filter.hide_action_types(&copilot_auth_action_types);
|
||||
filter.show_action_types(copilot_no_auth_action_types.iter());
|
||||
}
|
||||
}
|
||||
})
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue