Skip to content

Commit 494d3b8

Browse files
committed
gitk: Avoid Tcl error when switching views
Michele Ballabio <[email protected]> pointed out that gitk sometimes throws a Tcl error (can't read "yscreen") when switching views, and proposed a patch. This is a different way of fixing it which is a bit neater. Basically, in showview we only set yscreen if the selected commit is on screen to start with, and then we only scroll the canvas to bring it onscreen if yscreen is set and the same commit exists in the new view. Signed-off-by: Paul Mackerras <[email protected]>
1 parent cb8329a commit 494d3b8

File tree

1 file changed

+1
-3
lines changed

1 file changed

+1
-3
lines changed

gitk

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2102,8 +2102,6 @@ proc showview {n} {
21022102
set ybot [expr {[lindex $span 1] * $ymax}]
21032103
if {$ytop < $y && $y < $ybot} {
21042104
set yscreen [expr {$y - $ytop}]
2105-
} else {
2106-
set yscreen [expr {($ybot - $ytop) / 2}]
21072105
}
21082106
} elseif {[info exists pending_select]} {
21092107
set selid $pending_select
@@ -2164,7 +2162,7 @@ proc showview {n} {
21642162
set yf 0
21652163
set row {}
21662164
set selectfirst 0
2167-
if {$selid ne {} && [info exists commitrow($n,$selid)]} {
2165+
if {[info exists yscreen] && [info exists commitrow($n,$selid)]} {
21682166
set row $commitrow($n,$selid)
21692167
# try to get the selected row in the same position on the screen
21702168
set ymax [lindex [$canv cget -scrollregion] 3]

0 commit comments

Comments
 (0)