agent: Keyboard navigation improvements (#30274)
- Fix `ctrl-p` not working in the model selector - Select first entry when opening the context picker Release Notes: - Fixed `menu::SelectPrevious` keybindings not working in the agent panel's model selector.
This commit is contained in:
parent
0abee5668a
commit
9cff5cfe3a
4 changed files with 50 additions and 8 deletions
|
@ -1,5 +1,9 @@
|
|||
use anyhow::Result;
|
||||
use editor::{Editor, scroll::Autoscroll};
|
||||
use editor::{
|
||||
Editor,
|
||||
actions::{MoveDown, MoveUp},
|
||||
scroll::Autoscroll,
|
||||
};
|
||||
use gpui::{
|
||||
AnyElement, App, ClickEvent, Context, DismissEvent, Entity, EventEmitter, FocusHandle,
|
||||
Focusable, Length, ListSizingBehavior, ListState, MouseButton, MouseUpEvent, Render,
|
||||
|
@ -451,6 +455,10 @@ impl<D: PickerDelegate> Picker<D> {
|
|||
}
|
||||
}
|
||||
|
||||
pub fn editor_move_up(&mut self, _: &MoveUp, window: &mut Window, cx: &mut Context<Self>) {
|
||||
self.select_previous(&Default::default(), window, cx);
|
||||
}
|
||||
|
||||
fn select_previous(
|
||||
&mut self,
|
||||
_: &menu::SelectPrevious,
|
||||
|
@ -466,7 +474,16 @@ impl<D: PickerDelegate> Picker<D> {
|
|||
}
|
||||
}
|
||||
|
||||
fn select_first(&mut self, _: &menu::SelectFirst, window: &mut Window, cx: &mut Context<Self>) {
|
||||
pub fn editor_move_down(&mut self, _: &MoveDown, window: &mut Window, cx: &mut Context<Self>) {
|
||||
self.select_next(&Default::default(), window, cx);
|
||||
}
|
||||
|
||||
pub fn select_first(
|
||||
&mut self,
|
||||
_: &menu::SelectFirst,
|
||||
window: &mut Window,
|
||||
cx: &mut Context<Self>,
|
||||
) {
|
||||
let count = self.delegate.match_count();
|
||||
if count > 0 {
|
||||
self.set_selected_index(0, Some(Direction::Down), true, window, cx);
|
||||
|
@ -857,6 +874,8 @@ impl<D: PickerDelegate> Render for Picker<D> {
|
|||
.when(self.is_modal, |this| this.elevation_3(cx))
|
||||
.on_action(cx.listener(Self::select_next))
|
||||
.on_action(cx.listener(Self::select_previous))
|
||||
.on_action(cx.listener(Self::editor_move_down))
|
||||
.on_action(cx.listener(Self::editor_move_up))
|
||||
.on_action(cx.listener(Self::select_first))
|
||||
.on_action(cx.listener(Self::select_last))
|
||||
.on_action(cx.listener(Self::cancel))
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue