zeta: Add action to clear edit history (#21813)
Co-Authored-by: Antonio <antonio@zed.dev> Release Notes: - N/A --------- Co-authored-by: Antonio <antonio@zed.dev>
This commit is contained in:
parent
03efd0d1d9
commit
c6932d1f51
2 changed files with 22 additions and 3 deletions
|
@ -49,12 +49,19 @@ pub fn init(client: Arc<Client>, cx: &mut AppContext) {
|
|||
});
|
||||
}
|
||||
|
||||
if cx.has_flag::<ZetaFeatureFlag>() {
|
||||
cx.on_action(clear_zeta_edit_history);
|
||||
}
|
||||
|
||||
cx.observe_flag::<ZetaFeatureFlag, _>({
|
||||
let editors = editors.clone();
|
||||
let client = client.clone();
|
||||
move |_flag, cx| {
|
||||
move |active, cx| {
|
||||
let provider = all_language_settings(None, cx).inline_completions.provider;
|
||||
assign_inline_completion_providers(&editors, provider, &client, cx)
|
||||
assign_inline_completion_providers(&editors, provider, &client, cx);
|
||||
if active && !cx.is_action_available(&zeta::ClearHistory) {
|
||||
cx.on_action(clear_zeta_edit_history);
|
||||
}
|
||||
}
|
||||
})
|
||||
.detach();
|
||||
|
@ -73,6 +80,12 @@ pub fn init(client: Arc<Client>, cx: &mut AppContext) {
|
|||
.detach();
|
||||
}
|
||||
|
||||
fn clear_zeta_edit_history(_: &zeta::ClearHistory, cx: &mut AppContext) {
|
||||
if let Some(zeta) = zeta::Zeta::global(cx) {
|
||||
zeta.update(cx, |zeta, _| zeta.clear_history());
|
||||
}
|
||||
}
|
||||
|
||||
fn assign_inline_completion_providers(
|
||||
editors: &Rc<RefCell<HashMap<WeakView<Editor>, AnyWindowHandle>>>,
|
||||
provider: InlineCompletionProvider,
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue