Fix linux prompts (#14021)

Release Notes:

- N/A
This commit is contained in:
Conrad Irwin 2024-07-09 14:00:33 -06:00 committed by GitHub
parent 6c9da838b7
commit c65673feae
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -31,7 +31,7 @@ pub fn fallback_prompt_renderer(
detail: detail.map(ToString::to_string),
actions: actions.iter().map(ToString::to_string).collect(),
focus: cx.focus_handle(),
active_action_id: actions.len() - 1,
active_action_id: 0,
}
});
@ -60,21 +60,16 @@ impl FallbackPromptRenderer {
}
fn select_first(&mut self, _: &menu::SelectFirst, cx: &mut ViewContext<Self>) {
self.active_action_id = 0;
cx.notify();
}
fn select_last(&mut self, _: &menu::SelectLast, cx: &mut ViewContext<Self>) {
self.active_action_id = self.actions.len().saturating_sub(1);
cx.notify();
}
fn select_next(&mut self, _: &menu::SelectNext, cx: &mut ViewContext<Self>) {
self.active_action_id = (self.active_action_id + 1) % self.actions.len();
fn select_last(&mut self, _: &menu::SelectLast, cx: &mut ViewContext<Self>) {
self.active_action_id = 0;
cx.notify();
}
fn select_prev(&mut self, _: &menu::SelectPrev, cx: &mut ViewContext<Self>) {
fn select_next(&mut self, _: &menu::SelectNext, cx: &mut ViewContext<Self>) {
if self.active_action_id > 0 {
self.active_action_id -= 1;
} else {
@ -82,6 +77,11 @@ impl FallbackPromptRenderer {
}
cx.notify();
}
fn select_prev(&mut self, _: &menu::SelectPrev, cx: &mut ViewContext<Self>) {
self.active_action_id = (self.active_action_id + 1) % self.actions.len();
cx.notify();
}
}
impl Render for FallbackPromptRenderer {
@ -119,7 +119,7 @@ impl Render for FallbackPromptRenderer {
.child(detail)
}))
.child(h_flex().justify_end().gap_2().children(
self.actions.iter().rev().enumerate().map(|(ix, action)| {
self.actions.iter().enumerate().rev().map(|(ix, action)| {
ui::Button::new(ix, action.clone())
.label_size(LabelSize::Large)
.style(ButtonStyle::Filled)