Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Enable jumping back in main view #1138

Merged
merged 2 commits into from
Oct 4, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 15 additions & 1 deletion src/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -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)
{
Expand Down Expand Up @@ -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:
Expand Down
28 changes: 28 additions & 0 deletions test/main/goto-test
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -39,6 +43,18 @@ assert_equals 'commit-1.screen' <<EOF
2009-02-22 11:53 +0000 Committer o-' [master] Change: b


[main] 9d2a1bbf0046ec6b5e7a6faebb9ba9374bdbdee7 - commit 1 of 5 100%
EOF

assert_equals 'commit-1-back.screen' <<EOF
2009-03-28 13:22 +0000 Committer * [conflict-branch] Change: d'
2009-03-20 01:00 +0000 Committer * Change: d
2014-05-25 19:42 +0000 Unknown | * Unstaged changes
2009-03-11 12:38 +0000 Committer | * [conflict-master] Change: c'
2009-03-03 00:15 +0000 Committer | * Change: c
2009-02-22 11:53 +0000 Committer o-' [master] Change: b


[main] 9d2a1bbf0046ec6b5e7a6faebb9ba9374bdbdee7 - commit 1 of 5 100%
EOF

Expand All @@ -51,6 +67,18 @@ assert_equals 'commit-2.screen' <<EOF
2009-02-22 11:53 +0000 Committer o-' [master] Change: b


[main] fa878e5e6d838243fa59025ef314395fbebc790f - commit 2 of 5 100%
EOF

assert_equals 'commit-2-again.screen' <<EOF
2009-03-28 13:22 +0000 Committer * [conflict-branch] Change: d'
2009-03-20 01:00 +0000 Committer * Change: d
2014-05-25 19:42 +0000 Unknown | * Unstaged changes
2009-03-11 12:38 +0000 Committer | * [conflict-master] Change: c'
2009-03-03 00:15 +0000 Committer | * Change: c
2009-02-22 11:53 +0000 Committer o-' [master] Change: b


[main] fa878e5e6d838243fa59025ef314395fbebc790f - commit 2 of 5 100%
EOF

Expand Down