feat(core): Add Quicklist function to return all visible via ctrl+Q.
Some checks failed
CI / Check (macos-latest) (push) Has been cancelled
CI / Check (ubuntu-latest) (push) Has been cancelled
CI / Clippy (strict) (push) Has been cancelled
CI / Format (push) Has been cancelled
CI / Test (macos-latest) (push) Has been cancelled
CI / Test (ubuntu-latest) (push) Has been cancelled
Some checks failed
CI / Check (macos-latest) (push) Has been cancelled
CI / Check (ubuntu-latest) (push) Has been cancelled
CI / Clippy (strict) (push) Has been cancelled
CI / Format (push) Has been cancelled
CI / Test (macos-latest) (push) Has been cancelled
CI / Test (ubuntu-latest) (push) Has been cancelled
This commit is contained in:
@@ -132,7 +132,7 @@ async fn run_inner(
|
||||
}
|
||||
view_state = Some(vs);
|
||||
}
|
||||
Ok(MenuEvent::Selected(_) | MenuEvent::Cancelled) => {
|
||||
Ok(MenuEvent::Selected(_) | MenuEvent::Quicklist(_) | MenuEvent::Cancelled) => {
|
||||
break;
|
||||
}
|
||||
Err(broadcast::error::RecvError::Lagged(_)) => {}
|
||||
@@ -233,6 +233,7 @@ fn map_insert_mode(key: KeyEvent, filter_text: &mut String) -> Option<Action> {
|
||||
filter_text.pop();
|
||||
Some(Action::UpdateFilter(filter_text.clone()))
|
||||
}
|
||||
(KeyCode::Char('q'), KeyModifiers::CONTROL) => Some(Action::Quicklist),
|
||||
(KeyCode::Char(c), mods) if !mods.intersects(KeyModifiers::CONTROL | KeyModifiers::ALT) => {
|
||||
filter_text.push(c);
|
||||
Some(Action::UpdateFilter(filter_text.clone()))
|
||||
@@ -276,6 +277,7 @@ fn map_normal_mode(key: KeyEvent, pending: &mut PendingKey) -> Option<Action> {
|
||||
(KeyCode::Char('/'), m) if !m.intersects(KeyModifiers::CONTROL | KeyModifiers::ALT) => {
|
||||
Some(Action::SetMode(Mode::Insert))
|
||||
}
|
||||
(KeyCode::Char('q'), KeyModifiers::CONTROL) => Some(Action::Quicklist),
|
||||
(KeyCode::Char('q'), m) if !m.intersects(KeyModifiers::CONTROL | KeyModifiers::ALT) => {
|
||||
Some(Action::Cancel)
|
||||
}
|
||||
@@ -663,6 +665,28 @@ mod tests {
|
||||
assert_eq!(ft, "");
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn ctrl_q_maps_to_quicklist_insert() {
|
||||
let mut ft = String::new();
|
||||
let mut pending = PendingKey::None;
|
||||
let k = key_with_mods(KeyCode::Char('q'), KeyModifiers::CONTROL);
|
||||
assert_eq!(
|
||||
map_key_event(k, &mut ft, Mode::Insert, &mut pending),
|
||||
Some(Action::Quicklist)
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn ctrl_q_maps_to_quicklist_normal() {
|
||||
let mut ft = String::new();
|
||||
let mut pending = PendingKey::None;
|
||||
let k = key_with_mods(KeyCode::Char('q'), KeyModifiers::CONTROL);
|
||||
assert_eq!(
|
||||
map_key_event(k, &mut ft, Mode::Normal, &mut pending),
|
||||
Some(Action::Quicklist)
|
||||
);
|
||||
}
|
||||
|
||||
// -- Rendering tests (TestBackend) --
|
||||
|
||||
fn render_to_backend(width: u16, height: u16, vs: &ViewState, filter: &str) -> TestBackend {
|
||||
|
||||
Reference in New Issue
Block a user