From f531e463f0471ce41c51e19074a118482f36910f Mon Sep 17 00:00:00 2001 From: Abhijit Menon-Sen Date: Wed, 25 Jun 2008 16:06:50 +0530 Subject: [PATCH] git-gui: Don't select the wrong file if the last listed file is staged. Johannes Sixt noticed that if the last file in the list was staged, my earlier patch would display the diff for the penultimate file, but show the file _before_ that as being selected. This was due to my misunderstanding the lno argument to show_diff. This patch fixes the problem: lno is not decremented in the special case to handle the last item in the list (though we still need to use $lno-1 to find the right path for the next diff). Signed-off-by: Abhijit Menon-Sen Tested-by: Johannes Sixt Signed-off-by: Shawn O. Pearce --- git-gui.sh | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/git-gui.sh b/git-gui.sh index 980dc0b37..1bbae15a5 100755 --- a/git-gui.sh +++ b/git-gui.sh @@ -1806,14 +1806,16 @@ proc toggle_or_diff {w x y} { } else { global next_diff_p next_diff_w next_diff_i + set next_diff_w $w + if {$i < $ll} { set i [expr {$i + 1}] + set next_diff_i $i } else { + set next_diff_i $i set i [expr {$i - 1}] } - set next_diff_i $i - set next_diff_w $w set next_diff_p [lindex $file_lists($w) $i] if {$next_diff_p ne {} && $current_diff_path ne {}} { -- 2.30.2