diff --git a/src/main.c b/src/main.c index 7a87f4a74..7b37b2a7a 100644 --- a/src/main.c +++ b/src/main.c @@ -32,6 +32,8 @@ DEFINE_ALLOCATOR(realloc_reflogs, char *, 32) +static struct view_history main_view_history = { 0 }; + bool main_status_exists(struct view *view, enum line_type type) { @@ -570,7 +572,19 @@ main_request(struct view *view, enum request request, struct line *line) break; case REQ_PARENT: - goto_id(view, "%(commit)^", true, false); + if (push_view_history_state(&main_view_history, &view->pos, NULL)) { + goto_id(view, "%(commit)^", true, false); + } else { + report("Failed to save current view state"); + } + break; + + case REQ_BACK: + if (pop_view_history_state(&main_view_history, &view->pos, NULL)) { + redraw_view(view); + } else { + report("Already at start of history"); + } break; case REQ_MOVE_NEXT_MERGE: diff --git a/test/main/goto-test b/test/main/goto-test index 2fb28a10d..4ae5ec6e7 100755 --- a/test/main/goto-test +++ b/test/main/goto-test @@ -15,6 +15,10 @@ steps ' :save-display commit-1.screen :parent :save-display commit-2.screen + :back + :save-display commit-1-back.screen + :parent + :save-display commit-2-again.screen :parent :save-display commit-5.screen :parent @@ -39,6 +43,18 @@ assert_equals 'commit-1.screen' <