diff --git a/README.md b/README.md
index 8bf6b4a..1b01b66 100644
--- a/README.md
+++ b/README.md
@@ -171,20 +171,21 @@ The default key bindings can be overridden. Please refer to [default-keybind.tom
#### Commit List
-| Key | Description | Corresponding keybind |
-| --------------------------------- | -------------------------------------------------- | -------------------------------------------- |
-| Down/Up j/k | Move down/up | `navigate_down` `navigate_up` |
-| g/G | Go to top/bottom | `go_to_top` `go_to_bottom` |
-| Ctrl-f/b | Scroll page down/up | `page_down` `page_up` |
-| Ctrl-d/u | Scroll half page down/up | `half_page_down` `half_page_up` |
-| Ctrl-e/y | Scroll down/up | `scroll_down` `scroll_up` |
-| H/M/L | Select top/middle/bottom of the screen | `select_top` `select_middle` `select_bottom` |
-| Enter | Show commit details
Apply search (if searching) | `confirm` |
-| Tab | Open refs list | `ref_list_toggle` |
-| / | Start search | `search` |
-| Esc | Cancel search | `cancel` |
-| n/N | Go to next/previous search match | `go_to_next` `go_to_previous` |
-| c/C | Copy commit short/full hash | `short_copy` `full_copy` |
+| Key | Description | Corresponding keybind |
+| ------------------------------------ | -------------------------------------------------- | -------------------------------------------- |
+| Down/Up j/k | Move down/up | `navigate_down` `navigate_up` |
+| Alt-Down Alt-j | Move to parent commit | `go_to_parent` |
+| g/G | Go to top/bottom | `go_to_top` `go_to_bottom` |
+| Ctrl-f/b | Scroll page down/up | `page_down` `page_up` |
+| Ctrl-d/u | Scroll half page down/up | `half_page_down` `half_page_up` |
+| Ctrl-e/y | Scroll down/up | `scroll_down` `scroll_up` |
+| H/M/L | Select top/middle/bottom of the screen | `select_top` `select_middle` `select_bottom` |
+| Enter | Show commit details
Apply search (if searching) | `confirm` |
+| Tab | Open refs list | `ref_list_toggle` |
+| / | Start search | `search` |
+| Esc | Cancel search | `cancel` |
+| n/N | Go to next/previous search match | `go_to_next` `go_to_previous` |
+| c/C | Copy commit short/full hash | `short_copy` `full_copy` |
#### Commit Detail
diff --git a/assets/default-keybind.toml b/assets/default-keybind.toml
index b931cac..2213011 100644
--- a/assets/default-keybind.toml
+++ b/assets/default-keybind.toml
@@ -8,6 +8,7 @@ navigate_up = ["k", "up"]
navigate_down = ["j", "down"]
navigate_right = ["l", "right"]
navigate_left = ["h", "left"]
+go_to_parent = ["alt-j", "alt-down"]
go_to_top = ["g"]
go_to_bottom = ["shift-g"]
diff --git a/src/event.rs b/src/event.rs
index cf81a02..8c73fee 100644
--- a/src/event.rs
+++ b/src/event.rs
@@ -96,6 +96,7 @@ pub enum UserEvent {
NavigateLeft,
GoToTop,
GoToBottom,
+ GoToParent,
ScrollUp,
ScrollDown,
PageUp,
diff --git a/src/view/help.rs b/src/view/help.rs
index 5f5fef1..434fd73 100644
--- a/src/view/help.rs
+++ b/src/view/help.rs
@@ -173,6 +173,7 @@ fn build_lines(keybind: &KeyBind) -> (Vec>, Vec>) {
&[
(&[UserEvent::NavigateDown], "Move down"),
(&[UserEvent::NavigateUp], "Move up"),
+ (&[UserEvent::GoToParent], "Go to parent"),
(&[UserEvent::GoToTop], "Go to top"),
(&[UserEvent::GoToBottom], "Go to bottom"),
(&[UserEvent::PageDown], "Scroll page down"),
diff --git a/src/view/list.rs b/src/view/list.rs
index 82664f5..08f93aa 100644
--- a/src/view/list.rs
+++ b/src/view/list.rs
@@ -55,6 +55,9 @@ impl<'a> ListView<'a> {
UserEvent::NavigateUp => {
self.as_mut_list_state().select_prev();
}
+ UserEvent::GoToParent => {
+ self.as_mut_list_state().select_parent();
+ }
UserEvent::GoToTop => {
self.as_mut_list_state().select_first();
}
diff --git a/src/widget/commit_list.rs b/src/widget/commit_list.rs
index e71b91e..c3dcfea 100644
--- a/src/widget/commit_list.rs
+++ b/src/widget/commit_list.rs
@@ -165,6 +165,23 @@ impl<'a> CommitListState<'a> {
}
}
+ pub fn select_parent(&mut self) {
+ let target_commit = self.selected_commit_parent_hash().clone();
+ while target_commit.as_str() != self.selected_commit_hash().as_str() {
+ self.select_next();
+ }
+ }
+
+ pub fn selected_commit_parent_hash(&self) -> &CommitHash {
+ let selected_commit_hash = self.selected_commit_hash();
+
+ self.commits[self.current_selected_index()]
+ .commit
+ .parent_commit_hashes
+ .first()
+ .unwrap_or(selected_commit_hash)
+ }
+
pub fn select_prev(&mut self) {
if self.selected > 0 {
self.selected -= 1;