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

next commit from diff view #1053

Closed
delanym opened this issue Nov 27, 2020 · 1 comment
Closed

next commit from diff view #1053

delanym opened this issue Nov 27, 2020 · 1 comment

Comments

@delanym
Copy link

delanym commented Nov 27, 2020

How can I get to the next commit while in the diff view?
To go from one commit to the next and view their lines, from the main view, each commit includes these key presses

{ enter > scroll > tab > j/k }

But here the diff takes up half the screen. I want the whole screen when I'm reading lines changes.
If I press O to maximise diff view, there's no corresponding minimize to get back.
If I press m, I'm taken back to the main screen without the diff on the side, resulting in

{ enter > O > scroll > m > j/k }

or

{ d > scroll > m > j/k }

What I really want is

d > { scroll > j/k }
@koutcher
Copy link
Collaborator

d > { scroll > j/k } wouldn't be possible because the diff view has no notion of previous/next commit, only the main view does. enter > O > { scroll > j/k } once was possible but was removed by #835 to fix an inconsistent behaviour of the diff view. With a bit more mileage in hacking tig, I believe it could have been fixed differently by reworking #478. The following patch would give us the best of both worlds. If you maximize the split diff view with O, it will keep the special Up/Down keys behaviour while you stay in the view. Any change of principal view (including pressing d) will restore the normal Up/Down keys behaviour. The only limitation I can see is that, as Untracked changes and Unstaged changes lines in the main view open the status and stage views, reaching them with Up/Down will also result in restoring the normal Up/Down keys behaviour, but I think that's acceptable.

diff --git a/src/tig.c b/src/tig.c
index eedbf79..bf15151 100644
--- a/src/tig.c
+++ b/src/tig.c
@@ -242,7 +242,7 @@ view_driver(struct view *view, enum request request)
 
 	case REQ_NEXT:
 	case REQ_PREVIOUS:
-		if (view->parent && view == display[1]) {
+		if (view->parent) {
 			int line;
 
 			view = view->parent;
@@ -344,7 +344,6 @@ view_driver(struct view *view, enum request request)
 		if (view->prev && view->prev != view) {
 			maximize_view(view->prev, true);
 			view->prev = view;
-			view->parent = NULL;
 			break;
 		}
 		if (request == REQ_VIEW_CLOSE_NO_QUIT) {
diff --git a/src/view.c b/src/view.c
index 0447bc0..d7b5bd5 100644
--- a/src/view.c
+++ b/src/view.c
@@ -842,6 +842,9 @@ open_view(struct view *prev, struct view *view, enum open_flags flags)
 	if (prev && prev->parent && prev == display[1])
 		prev = prev->parent;
 
+	if (view != display[0])
+		view->parent = NULL;
+
 	if (!view->keymap)
 		view->keymap = get_keymap(view->name, strlen(view->name));
 	load_view(view, prev ? prev : view, flags);

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants