Commit Diff


commit - 760da9be871e5ddb0810ad8d09b20016fcafa770
commit + c26e21eef791002a56bc9c626f5a94cba4165d09
blob - 04f4fa4c3cfbec150ae760c462178f05c608149e
blob + 4801c9c97f0a63d5a0351ee3ab00ca40e143e5f5
--- regress/tog/diff.sh
+++ regress/tog/diff.sh
@@ -476,6 +476,69 @@ test_diff_commit_keywords()
 	ret=$?
 	if [ $ret -ne 0 ]; then
 		diff -u "$testroot/view.expected" "$testroot/view"
+		test_done "$testroot" "$ret"
+		return 1
+	fi
+
+	test_done "$testroot" "$ret"
+}
+
+test_diff_horizontal_scroll()
+{
+	test_init diff_horizontal_scroll
+
+	local commit_id1=`git_show_head $testroot/repo`
+	local alpha_id_old=`get_blob_id $testroot/repo "" alpha`
+
+	{
+		echo -n "01234567890123456789012345678901234567890123456789"
+		echo "0123456789012345678901234567890123"
+	} >> $testroot/repo/alpha
+
+	git_commit $testroot/repo -m "scroll"
+	local author_time=`git_show_author_time $testroot/repo`
+	local date=`date -u -r $author_time +"%a %b %e %X %Y UTC"`
+	local head_id=`git_show_head $testroot/repo`
+	local head_id_truncated=`trim_obj_id 13 $head_id`
+	local alpha_id=`get_blob_id $testroot/repo "" alpha`
+
+	cat <<EOF >$TOG_TEST_SCRIPT
+3l
+SCREENDUMP
+EOF
+
+	cat <<EOF >$testroot/view.expected
+[1/20] diff $commit_id1 $head_id_truncated
+ $head_id (master)
+Flan Hacker <flan_hacker@openbsd.org>
+$date
+
+
+
+ha  |  1+  0-
+
+ changed, 1 insertion(+), 0 deletions(-)
+
+ - $commit_id1
+ + $head_id
+ $alpha_id_old
+ $alpha_id
+pha
+pha
++1,2 @@
+
+5678901234567890123456789012345678901234567890123456789012345678901234567890123
+
+
+
+(END)
+EOF
+
+	cd $testroot/repo && tog diff $commit_id1 $head_id
+	cmp -s $testroot/view.expected $testroot/view
+	ret=$?
+	if [ $ret -ne 0 ]; then
+		diff -u $testroot/view.expected $testroot/view
 		test_done "$testroot" "$ret"
 		return 1
 	fi
@@ -488,3 +551,4 @@ run_test test_diff_contiguous_commits
 run_test test_diff_arbitrary_commits
 run_test test_diff_J_keymap
 run_test test_diff_commit_keywords
+run_test test_diff_horizontal_scroll
blob - b8146cfeb30ec9156a8c21c672e2e62f2b8666cd
blob + 38cb4a714d73a34d03df0760e883cf0196000dbc
--- tog/tog.c
+++ tog/tog.c
@@ -2303,8 +2303,6 @@ format_line(wchar_t **wlinep, int *widthp, int *scroll
 	free(exstr);
 	if (err)
 		return err;
-
-	scrollx = span_wline(&cols, 0, wline, nscroll, col_tab_align);
 
 	if (wlen > 0 && wline[wlen - 1] == L'\n') {
 		wline[wlen - 1] = L'\0';
@@ -2314,6 +2312,8 @@ format_line(wchar_t **wlinep, int *widthp, int *scroll
 		wline[wlen - 1] = L'\0';
 		wlen--;
 	}
+
+	scrollx = span_wline(&cols, 0, wline, nscroll, col_tab_align);
 
 	i = span_wline(&cols, scrollx, wline, wlimit, col_tab_align);
 	wline[i] = L'\0';