gitk: Fix problem with target row not being in scroll region
[gitweb.git] / gitk
diff --git a/gitk b/gitk
index 19325086bf68951df6a85d17beb1a513cbd8d64a..1125f68d35f1e58bfd3cdf06f3cb8ae8669415f1 100755 (executable)
--- a/gitk
+++ b/gitk
@@ -5429,7 +5429,7 @@ proc selectline {l isnew} {
     global commentend idtags linknum
     global mergemax numcommits pending_select
     global cmitmode showneartags allcommits
-    global targetrow targetid
+    global targetrow targetid lastscrollrows
 
     catch {unset pending_select}
     $canv delete hover
@@ -5440,6 +5440,11 @@ proc selectline {l isnew} {
     set id [commitonrow $l]
     set targetid $id
     set targetrow $l
+    set selectedline $l
+    set currentid $id
+    if {$lastscrollrows < $numcommits} {
+       setcanvscroll
+    }
 
     set y [expr {$canvy0 + $l * $linespc}]
     set ymax [lindex [$canv cget -scrollregion] 3]
@@ -5483,8 +5488,6 @@ proc selectline {l isnew} {
        addtohistory [list selbyid $id]
     }
 
-    set selectedline $l
-    set currentid $id
     $sha1entry delete 0 end
     $sha1entry insert 0 $id
     $sha1entry selection from 0