Add select_first and select_last bindings to outline view
Co-Authored-By: Antonio Scandurra <me@as-cii.com> Co-Authored-By: Nathan Sobo <nathan@zed.dev>
This commit is contained in:
parent
ea69dcd42a
commit
b7561c6cef
8 changed files with 66 additions and 47 deletions
|
@ -3,7 +3,7 @@ use fuzzy::{match_strings, StringMatch, StringMatchCandidate};
|
|||
use gpui::{
|
||||
action,
|
||||
elements::*,
|
||||
keymap::{self, menu, Binding},
|
||||
keymap::{self, Binding},
|
||||
AppContext, Axis, Element, ElementBox, Entity, MutableAppContext, RenderContext, View,
|
||||
ViewContext, ViewHandle,
|
||||
};
|
||||
|
@ -11,7 +11,10 @@ use parking_lot::Mutex;
|
|||
use postage::watch;
|
||||
use std::{cmp, sync::Arc};
|
||||
use theme::ThemeRegistry;
|
||||
use workspace::{AppState, Settings, Workspace};
|
||||
use workspace::{
|
||||
menu::{Confirm, SelectNext, SelectPrev},
|
||||
AppState, Settings, Workspace,
|
||||
};
|
||||
|
||||
#[derive(Clone)]
|
||||
pub struct ThemeSelectorParams {
|
||||
|
@ -30,7 +33,6 @@ pub struct ThemeSelector {
|
|||
selected_index: usize,
|
||||
}
|
||||
|
||||
action!(Confirm);
|
||||
action!(Toggle, ThemeSelectorParams);
|
||||
action!(Reload, ThemeSelectorParams);
|
||||
|
||||
|
@ -45,7 +47,6 @@ pub fn init(params: ThemeSelectorParams, cx: &mut MutableAppContext) {
|
|||
Binding::new("cmd-k cmd-t", Toggle(params.clone()), None),
|
||||
Binding::new("cmd-k t", Reload(params.clone()), None),
|
||||
Binding::new("escape", Toggle(params.clone()), Some("ThemeSelector")),
|
||||
Binding::new("enter", Confirm, Some("ThemeSelector")),
|
||||
]);
|
||||
}
|
||||
|
||||
|
@ -136,7 +137,7 @@ impl ThemeSelector {
|
|||
}
|
||||
}
|
||||
|
||||
fn select_prev(&mut self, _: &menu::SelectPrev, cx: &mut ViewContext<Self>) {
|
||||
fn select_prev(&mut self, _: &SelectPrev, cx: &mut ViewContext<Self>) {
|
||||
if self.selected_index > 0 {
|
||||
self.selected_index -= 1;
|
||||
}
|
||||
|
@ -145,7 +146,7 @@ impl ThemeSelector {
|
|||
cx.notify();
|
||||
}
|
||||
|
||||
fn select_next(&mut self, _: &menu::SelectNext, cx: &mut ViewContext<Self>) {
|
||||
fn select_next(&mut self, _: &SelectNext, cx: &mut ViewContext<Self>) {
|
||||
if self.selected_index + 1 < self.matches.len() {
|
||||
self.selected_index += 1;
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue