Skip to content

Commit b7efd8a

Browse files
committed
Use correct line when using :parent in blame view
This fixes the bug described in the parent commit. `blame->lineno` is only used here and in #1370, so we can either do this or we could shift all the entries in `blame->lineno` by 1.
1 parent 2067fdc commit b7efd8a

File tree

2 files changed

+5
-4
lines changed

2 files changed

+5
-4
lines changed

src/blame.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -335,7 +335,7 @@ setup_blame_parent_line(struct view *view, struct blame *blame)
335335
blamed_lineno = atoi(pos + 1);
336336

337337
} else if (*line == '+' && parent_lineno != -1) {
338-
if (blame->lineno == blamed_lineno - 1 &&
338+
if (blame->lineno == blamed_lineno &&
339339
!strcmp(blame->text, line + 1)) {
340340
view->pos.lineno = parent_lineno ? parent_lineno - 1 : 0;
341341
break;

test/blame/navigation-parent-test

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,9 @@ steps '
2222

2323
test_tig blame +36 project/Build.scala
2424

25-
# This demonstrates a BUG: after pressing ',' we stay at line 36, as shown in the status
26-
# bar. Line 36 has nothing to do with line 36 of the original commit.
25+
# This shows that after pressing ',' we should be positioned on line 40
26+
# (starting with "clean in common"), as shown in the status bar. We should *not*
27+
# stay on line 36.
2728
assert_equals 'recursive-blame.screen' <<EOF
2829
90286e0 Jonas Fonseca 2013-10-14 14:56 -0400 22| "-feature",
2930
90286e0 Jonas Fonseca 2013-10-14 14:56 -0400 23| "-encoding", "utf8"
@@ -53,5 +54,5 @@ assert_equals 'recursive-blame.screen' <<EOF
5354
4edd069 Jonas Fonseca 2013-10-17 20:34 -0400 47| richards,
5455
90286e0 Jonas Fonseca 2013-10-14 14:56 -0400 48| tracer
5556
90286e0 Jonas Fonseca 2013-10-14 14:56 -0400 49| )
56-
[blame] 90286e0752016a6bca30dfa7ca236d1f99345eb8 changed project/Build.scala - line 36 of 63 77%
57+
[blame] 90286e0752016a6bca30dfa7ca236d1f99345eb8 changed project/Build.scala - line 40 of 63 77%
5758
EOF

0 commit comments

Comments
 (0)