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:
Max Brunsfeld 2022-01-14 10:45:37 -08:00
parent ea69dcd42a
commit b7561c6cef
8 changed files with 66 additions and 47 deletions

View file

@ -23,6 +23,7 @@ struct Pending {
context: Option<Context>,
}
#[derive(Default)]
pub struct Keymap(Vec<Binding>);
pub struct Binding {
@ -153,24 +154,6 @@ impl Keymap {
}
}
pub mod menu {
use crate::action;
action!(SelectPrev);
action!(SelectNext);
}
impl Default for Keymap {
fn default() -> Self {
Self(vec![
Binding::new("up", menu::SelectPrev, Some("menu")),
Binding::new("ctrl-p", menu::SelectPrev, Some("menu")),
Binding::new("down", menu::SelectNext, Some("menu")),
Binding::new("ctrl-n", menu::SelectNext, Some("menu")),
])
}
}
impl Binding {
pub fn new<A: Action>(keystrokes: &str, action: A, context: Option<&str>) -> Self {
let context = if let Some(context) = context {