-
Notifications
You must be signed in to change notification settings - Fork 632
Use correct line from parent on recursive blame on blob #1370
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
Conversation
Thank you very much! I haven't looked into the details at this point, but I did compile this, and it does seem to solve the problem and work well for me so far. Adding a test for this also seems very nice.
Interesting. It'd make sense to me if the behavior of |
I should move this to a separate bug report, but here are a couple of debugging nuggets about the change of the behavior of The reproduction of the bug is exactly the same as #1369, except you press
So, the difference is probably caused by a different input to the |
After a bit more debugging, I think the fix might be: diff --git a/src/blame.c b/src/blame.c
index dc2888f8..56278952 100644
--- a/src/blame.c
+++ b/src/blame.c
@@ -332,7 +332,7 @@ setup_blame_parent_line(struct view *view, struct blame *blame)
blamed_lineno = atoi(pos + 1);
} else if (*line == '+' && parent_lineno != -1) {
- if (blame->lineno == blamed_lineno &&
+ if (blame->lineno == blamed_lineno - 1 &&
!strcmp(blame->text, line + 1)) {
view->pos.lineno = parent_lineno ? parent_lineno - 1 : 0;
break; The main question is whether it's better to do this or to shift all the Update: The only other place where Update: #1372 |
@krobelus observed in jonas#1370 that this behavior, fixed in ca0809d, regressed again in 2280734. This bug is similar to, but not identical with, jonas#1369. The easiest way to observe the bug is to run `tig blame +28 tig-2.5.12 -- src/diff.c` and press `,`. The problem is that the view stays on line 28 instead of jumping to the corresponding line.
test/blame/b-key-navigation-test
Outdated
:save-display recursive-blame.screen | ||
' | ||
|
||
test_tig blame +27 project/Build.scala |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
These aren't really problems, but I copied this test to make a test for the ,
key bug in #1372, and we could coordinate the two tests.
- If you use line 36 here, it works as an example for both
,
andb
keys - You could rename the file to something like
navigation-b-key-test
, so that the two tests get placed next to each other. (This seems slightly simpler than combining them into one test).
test/blame/b-key-navigation-test
Outdated
|
||
test_tig blame +27 project/Build.scala | ||
|
||
# This shows that after pressing 'b' we should be positioned the line starting |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Also not really a problem, but this confused me at first. It'd help if you at least added the expected line number and the fact that it's shown in the status bar.
Also, there's a typo, "on" is missing after "positioned".
Here's the comment I've come up with for the corresponding spot in #1372:
This shows that after pressing ',' we should be positioned on line 40 (starting with "clean in common"), as shown in the status bar. We should not stay on line 36.
src/blame.c
Outdated
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Very minor: the commit (and PR) title could say "...from ancestor" instead of "...from parent" to be clearer and less confusable with #1372.
7312d07
to
a9f389b
Compare
Running tig blame +28 tig-2.5.12 -- src/diff.c and pressing "b" should keep the line containing "const char *diff_argv[] = }" selected. It actually moves the selection somewhere else. This regressed in ca0809d (Fix cursor position after "Move to parent" in blame view, 2019-11-29). That commit only meant to change "," (":back" or ":parent"). When we press "b" (":view-blame"), we want to use the original behavior from ba7c7d3 (Use file and line number information when loading blame for commit, 2009-02-07). Do that. (Note that the behavior fixed by ca0809d regressed in 2280734 (Enable textconv in the blame view and fix blame -L (jonas#1190), 2022-06-03). I have not yet figured out what's going on, but this patch shouldn't make that worse.) Fixes jonas#1369
a9f389b
to
5dcfc9c
Compare
Running
and pressing "b" should keep the line containing "const char *diff_argv[]
= }" selected. It actually moves the selection somewhere else.
This regressed in ca0809d (Fix cursor position after "Move to parent"
in blame view, 2019-11-29).
Commit ca0809d was only about "," (":back" or ":parent"). When we press
"b" (":view-blame"), we want to use the old behavior (originally added in
ba7c7d3 (Use file and line number information when loading blame for commit,
2009-02-07)). Do that.
(Note that the behavior fixed by ca0809d regressed in 2280734 (Enable
textconv in the blame view and fix blame -L (#1190), 2022-06-03). I have
not yet figured out what's going on, but this patch shouldn't make that worse.)
Fixes #1369