diff --git a/src/app/input/navigate.rs b/src/app/input/navigate.rs index 6accb22f..426864e6 100644 --- a/src/app/input/navigate.rs +++ b/src/app/input/navigate.rs @@ -101,6 +101,27 @@ impl App { return; } + if self + .state + .keybinds + .navigate + .workspace_up + .matches_direct_key(raw_key) + { + self.state.move_selected_workspace_by_visible_delta(-1); + return; + } + if self + .state + .keybinds + .navigate + .workspace_down + .matches_direct_key(raw_key) + { + self.state.move_selected_workspace_by_visible_delta(1); + return; + } + if let Some(action) = navigate_reserved_action_for_key(&self.state, raw_key) { self.execute_tui_navigate_action(action, ActionContext::Navigate); return; @@ -2465,6 +2486,37 @@ last_pane = "prefix+tab" assert_eq!(app.state.mode, Mode::RenamePane); } + #[test] + fn app_navigate_mode_workspace_down_moves_selection() { + let mut app = app_with_test_workspaces(&["one", "two"]); + app.state.mode = Mode::Navigate; + + app.handle_navigate_key(TerminalKey::new(KeyCode::Down, KeyModifiers::empty())); + + assert_eq!(app.state.selected, 1); + assert_eq!(app.state.mode, Mode::Navigate); + } + + #[test] + fn app_navigate_mode_workspace_keys_are_configurable() { + let mut app = app_with_test_workspaces(&["one", "two"]); + let config: Config = toml::from_str( + r#" +[keys] +navigate_workspace_down = "j" +navigate_pane_down = "ctrl+j" +"#, + ) + .unwrap(); + app.state.keybinds = config.keybinds(); + app.state.mode = Mode::Navigate; + + app.handle_navigate_key(TerminalKey::new(KeyCode::Char('j'), KeyModifiers::empty())); + + assert_eq!(app.state.selected, 1); + assert_eq!(app.state.mode, Mode::Navigate); + } + #[tokio::test] async fn prefix_focus_pane_is_one_shot_and_returns_to_terminal() { let (_api_tx, api_rx) = tokio::sync::mpsc::unbounded_channel();