Introduce UI affordances to make enabling/disabling inline completions easier (#22894)
Release Notes: - N/A --------- Co-authored-by: Thorsten <thorsten@zed.dev>
This commit is contained in:
parent
38fbc73ac4
commit
341972c79c
3 changed files with 62 additions and 15 deletions
|
@ -204,23 +204,17 @@ impl Render for InlineCompletionButton {
|
|||
return div();
|
||||
}
|
||||
|
||||
let this = cx.view().clone();
|
||||
div().child(
|
||||
IconButton::new("zeta", IconName::ZedPredict)
|
||||
.tooltip(|cx| {
|
||||
Tooltip::with_meta(
|
||||
"Zed Predict",
|
||||
Some(&RateCompletions),
|
||||
"Click to rate completions",
|
||||
cx,
|
||||
)
|
||||
PopoverMenu::new("zeta")
|
||||
.menu(move |cx| {
|
||||
Some(this.update(cx, |this, cx| this.build_zeta_context_menu(cx)))
|
||||
})
|
||||
.on_click(cx.listener(|this, _, cx| {
|
||||
if let Some(workspace) = this.workspace.upgrade() {
|
||||
workspace.update(cx, |workspace, cx| {
|
||||
RateCompletionModal::toggle(workspace, cx)
|
||||
});
|
||||
}
|
||||
})),
|
||||
.anchor(Corner::BottomRight)
|
||||
.trigger(
|
||||
IconButton::new("zeta", IconName::ZedPredict)
|
||||
.tooltip(|cx| Tooltip::text("Zed Predict", cx)),
|
||||
),
|
||||
)
|
||||
}
|
||||
}
|
||||
|
@ -360,6 +354,25 @@ impl InlineCompletionButton {
|
|||
})
|
||||
}
|
||||
|
||||
fn build_zeta_context_menu(&self, cx: &mut ViewContext<Self>) -> View<ContextMenu> {
|
||||
let workspace = self.workspace.clone();
|
||||
ContextMenu::build(cx, |menu, cx| {
|
||||
self.build_language_settings_menu(menu, cx)
|
||||
.separator()
|
||||
.entry(
|
||||
"Rate Completions",
|
||||
Some(RateCompletions.boxed_clone()),
|
||||
move |cx| {
|
||||
workspace
|
||||
.update(cx, |workspace, cx| {
|
||||
RateCompletionModal::toggle(workspace, cx)
|
||||
})
|
||||
.ok();
|
||||
},
|
||||
)
|
||||
})
|
||||
}
|
||||
|
||||
pub fn update_enabled(&mut self, editor: View<Editor>, cx: &mut ViewContext<Self>) {
|
||||
let editor = editor.read(cx);
|
||||
let snapshot = editor.buffer().read(cx).snapshot(cx);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue