mirror of
https://github.com/zed-industries/zed.git
synced 2025-01-23 18:32:17 +00:00
zeta: Show keybinding in completion rating buttons in review modal (#22985)
This PR also removes the `ThumbsUp` action that wasn't being triggered correctly. We didn't have it's counterpart `ThumbsDown`, too, so I mostly assumed it would be harmless to remove `ThumbsUp` as well. <img width="800" alt="Screenshot 2025-01-10 at 6 18 44 PM" src="https://github.com/user-attachments/assets/9fd5da9f-9dff-454d-9f31-c02f1370b937" /> Release Notes: - N/A --------- Co-authored-by: Marshall Bowers <elliott.codes@gmail.com> # Conflicts: # crates/zeta/src/rate_completion_modal.rs
This commit is contained in:
parent
6e1e392853
commit
395d2e7d46
2 changed files with 15 additions and 16 deletions
|
@ -805,7 +805,8 @@
|
|||
"context": "RateCompletionModal",
|
||||
"use_key_equivalents": true,
|
||||
"bindings": {
|
||||
"cmd-enter": "zeta::ThumbsUp",
|
||||
"cmd-shift-enter": "zeta::ThumbsUpActiveCompletion",
|
||||
"cmd-shift-backspace": "zeta::ThumbsDownActiveCompletion",
|
||||
"shift-down": "zeta::NextEdit",
|
||||
"shift-up": "zeta::PreviousEdit",
|
||||
"right": "zeta::PreviewCompletion"
|
||||
|
|
|
@ -13,8 +13,6 @@ actions!(
|
|||
zeta,
|
||||
[
|
||||
RateCompletions,
|
||||
ThumbsUp,
|
||||
ThumbsDown,
|
||||
ThumbsUpActiveCompletion,
|
||||
ThumbsDownActiveCompletion,
|
||||
NextEdit,
|
||||
|
@ -71,6 +69,7 @@ impl RateCompletionModal {
|
|||
|
||||
pub fn new(zeta: Model<Zeta>, cx: &mut ViewContext<Self>) -> Self {
|
||||
let subscription = cx.observe(&zeta, |_, _, cx| cx.notify());
|
||||
|
||||
Self {
|
||||
zeta,
|
||||
selected_index: 0,
|
||||
|
@ -148,7 +147,7 @@ impl RateCompletionModal {
|
|||
cx.notify();
|
||||
}
|
||||
|
||||
pub fn thumbs_up_active(&mut self, _: &ThumbsUpActiveCompletion, cx: &mut ViewContext<Self>) {
|
||||
fn thumbs_up_active(&mut self, _: &ThumbsUpActiveCompletion, cx: &mut ViewContext<Self>) {
|
||||
self.zeta.update(cx, |zeta, cx| {
|
||||
if let Some(active) = &self.active_completion {
|
||||
zeta.rate_completion(
|
||||
|
@ -368,6 +367,7 @@ impl RateCompletionModal {
|
|||
fn render_active_completion(&mut self, cx: &mut ViewContext<Self>) -> Option<impl IntoElement> {
|
||||
let active_completion = self.active_completion.as_ref()?;
|
||||
let completion_id = active_completion.completion.id;
|
||||
let focus_handle = &self.focus_handle(cx);
|
||||
|
||||
let border_color = cx.theme().colors().border;
|
||||
let bg_color = cx.theme().colors().editor_background;
|
||||
|
@ -468,12 +468,6 @@ impl RateCompletionModal {
|
|||
.gap_1()
|
||||
.child(
|
||||
Button::new("bad", "Bad Completion")
|
||||
.key_binding(KeyBinding::for_action_in(
|
||||
&ThumbsDown,
|
||||
&self.focus_handle(cx),
|
||||
cx,
|
||||
))
|
||||
.style(ButtonStyle::Filled)
|
||||
.icon(IconName::ThumbsDown)
|
||||
.icon_size(IconSize::Small)
|
||||
.icon_position(IconPosition::Start)
|
||||
|
@ -483,6 +477,11 @@ impl RateCompletionModal {
|
|||
Tooltip::text("Explain what's bad about it before reporting it", cx)
|
||||
})
|
||||
})
|
||||
.key_binding(KeyBinding::for_action_in(
|
||||
&ThumbsDownActiveCompletion,
|
||||
focus_handle,
|
||||
cx,
|
||||
))
|
||||
.on_click(cx.listener(move |this, _, cx| {
|
||||
this.thumbs_down_active(
|
||||
&ThumbsDownActiveCompletion,
|
||||
|
@ -492,16 +491,15 @@ impl RateCompletionModal {
|
|||
)
|
||||
.child(
|
||||
Button::new("good", "Good Completion")
|
||||
.key_binding(KeyBinding::for_action_in(
|
||||
&ThumbsUp,
|
||||
&self.focus_handle(cx),
|
||||
cx,
|
||||
))
|
||||
.style(ButtonStyle::Filled)
|
||||
.icon(IconName::ThumbsUp)
|
||||
.icon_size(IconSize::Small)
|
||||
.icon_position(IconPosition::Start)
|
||||
.disabled(rated)
|
||||
.key_binding(KeyBinding::for_action_in(
|
||||
&ThumbsUpActiveCompletion,
|
||||
focus_handle,
|
||||
cx,
|
||||
))
|
||||
.on_click(cx.listener(move |this, _, cx| {
|
||||
this.thumbs_up_active(&ThumbsUpActiveCompletion, cx);
|
||||
})),
|
||||
|
|
Loading…
Reference in a new issue