gitk: Fix bug where current row number display stops working
The display of the current row number would stop working if the user clicked on a line, or if selectedline got unset for any other reason, because the trace on it got lost when it was unselected. This fixes it by changing the places that unset selectedline to set it to the empty string instead, and the places that tested for it being set or unset to compare it with the empty string. Thus it never gets unset now. This actually simplified the code in a few places since it can be compared for equality with a row number now without first testing if it is set. Signed-off-by: Paul Mackerras <paulus@samba.org>
Paul Mackerras committed
May 20, 2008 at 20:51 UTC
94b4a69f758131a6282363e1717235a03c3885ef
1 file changed
+23
-23
gitk
+23
-23
@@ -495,7 +495,7 @@ proc reloadcommits {} {
495
stop_rev_list $curview
496
}
497
resetvarcs $curview
498
- catch {unset selectedline}
498
+ set selectedline {}
499
catch {unset currentid}
500
catch {unset thickerline}
501
catch {unset treediffs}
@@ -927,7 +927,7 @@ proc removefakerow {id} {
927
modify_arc $v $a $i
928
if {[info exist currentid] && $id eq $currentid} {
929
unset currentid
930
- unset selectedline
930
+ set selectedline {}
931
}
932
if {[info exists targetid] && $targetid eq $id} {
933
set targetid $p
@@ -1838,7 +1838,7 @@ proc makewindow {} {
1838
pack .tf.bar.rowlabel .tf.bar.rownum .tf.bar.rowlabel2 .tf.bar.numcommits \
1839
-side left
1840
global selectedline
1841
- trace add variable selectedline {write unset} selectedline_change
1841
+ trace add variable selectedline write selectedline_change
1842
1843
# Status label and progress bar
1844
set statusw .tf.bar.status
@@ -2185,7 +2185,7 @@ proc windows_mousewheel_redirector {W X Y D} {
2185
proc selectedline_change {n1 n2 op} {
2186
global selectedline rownumsel
2187
2188
- if {$op eq "unset"} {
2188
+ if {$selectedline eq {}} {
2189
set rownumsel {}
2190
} else {
2191
set rownumsel [expr {$selectedline + 1}]
@@ -3274,7 +3274,7 @@ proc showview {n} {
3274
set ytop [expr {[lindex $span 0] * $ymax}]
3275
set ybot [expr {[lindex $span 1] * $ymax}]
3276
set yscreen [expr {($ybot - $ytop) / 2}]
3277
- if {[info exists selectedline]} {
3277
+ if {$selectedline ne {}} {
3278
set selid $currentid
3279
set y [yc $selectedline]
3280
if {$ytop < $y && $y < $ybot} {
@@ -3388,7 +3388,7 @@ proc bolden {row font} {
3388
3389
lappend boldrows $row
3390
$canv itemconf $linehtag($row) -font $font
3391
- if {[info exists selectedline] && $row == $selectedline} {
3391
+ if {$row == $selectedline} {
3392
$canv delete secsel
3393
set t [eval $canv create rect [$canv bbox $linehtag($row)] \
3394
-outline {{}} -tags secsel \
@@ -3402,7 +3402,7 @@ proc bolden_name {row font} {
3402
3403
lappend boldnamerows $row
3404
$canv2 itemconf $linentag($row) -font $font
3405
- if {[info exists selectedline] && $row == $selectedline} {
3405
+ if {$row == $selectedline} {
3406
$canv2 delete secsel
3407
set t [eval $canv2 create rect [$canv2 bbox $linentag($row)] \
3408
-outline {{}} -tags secsel \
@@ -3831,7 +3831,7 @@ proc askrelhighlight {row id} {
3831
global descendent highlight_related iddrawn rhighlights
3832
global selectedline ancestor
3833
3834
- if {![info exists selectedline]} return
3834
+ if {$selectedline eq {}} return
3835
set isbold 0
3836
if {$highlight_related eq [mc "Descendant"] ||
3837
$highlight_related eq [mc "Not descendant"]} {
@@ -4005,7 +4005,7 @@ proc visiblerows {} {
4005
4006
proc layoutmore {} {
4007
global commitidx viewcomplete curview
4008
- global numcommits pending_select selectedline curview
4008
+ global numcommits pending_select curview
4009
global lastscrollset lastscrollrows commitinterest
4010
4011
if {$lastscrollrows < 100 || $viewcomplete($curview) ||
@@ -4916,7 +4916,7 @@ proc drawcmittext {id row col} {
4916
-text $name -font $nfont -tags text]
4917
set linedtag($row) [$canv3 create text 3 $y -anchor w -fill $fgcolor \
4918
-text $date -font mainfont -tags text]
4919
- if {[info exists selectedline] && $selectedline == $row} {
4919
+ if {$selectedline == $row} {
4920
make_secsel $row
4921
}
4922
set xr [expr {$xt + [font measure $font $headline]}]
@@ -5107,7 +5107,7 @@ proc drawvisible {} {
5107
if {$endrow >= $vrowmod($curview)} {
5108
update_arcrows $curview
5109
}
5110
- if {[info exists selectedline] &&
5110
+ if {$selectedline ne {} &&
5111
$row <= $selectedline && $selectedline <= $endrow} {
5112
set targetrow $selectedline
5113
} elseif {[info exists targetid]} {
@@ -5427,7 +5427,7 @@ proc dofind {{dirn 1} {wrap 1}} {
5427
}
5428
focus .
5429
if {$findstring eq {} || $numcommits == 0} return
5430
- if {![info exists selectedline]} {
5430
+ if {$selectedline eq {}} {
5431
set findstartline [lindex [visiblerows] [expr {$dirn < 0}]]
5432
} else {
5433
set findstartline $selectedline
@@ -5623,7 +5623,7 @@ proc markmatches {canv l str tag matches font row} {
5623
[expr {$x0+$xlen+2}] $y1 \
5624
-outline {} -tags [list match$l matches] -fill yellow]
5625
$canv lower $t
5626
- if {[info exists selectedline] && $row == $selectedline} {
5626
+ if {$row == $selectedline} {
5627
$canv raise $t secsel
5628
}
5629
}
@@ -5782,7 +5782,7 @@ proc appendrefs {pos ids var} {
5782
proc dispneartags {delay} {
5783
global selectedline currentid showneartags tagphase
5784
5785
- if {![info exists selectedline] || !$showneartags} return
5785
+ if {$selectedline eq {} || !$showneartags} return
5786
after cancel dispnexttag
5787
if {$delay} {
5788
after 200 dispnexttag
@@ -5796,7 +5796,7 @@ proc dispneartags {delay} {
5796
proc dispnexttag {} {
5797
global selectedline currentid showneartags tagphase ctext
5798
5799
- if {![info exists selectedline] || !$showneartags} return
5799
+ if {$selectedline eq {} || !$showneartags} return
5800
switch -- $tagphase {
5801
0 {
5802
set dtags [desctags $currentid]
@@ -6018,7 +6018,7 @@ proc sellastline {} {
6018
proc selnextline {dir} {
6019
global selectedline
6020
focus .
6021
- if {![info exists selectedline]} return
6021
+ if {$selectedline eq {}} return
6022
set l [expr {$selectedline + $dir}]
6023
unmarkmatches
6024
selectline $l 1
@@ -6033,7 +6033,7 @@ proc selnextpage {dir} {
6033
}
6034
allcanvs yview scroll [expr {$dir * $lpp}] units
6035
drawvisible
6036
- if {![info exists selectedline]} return
6036
+ if {$selectedline eq {}} return
6037
set l [expr {$selectedline + $dir * $lpp}]
6038
if {$l < 0} {
6039
set l 0
@@ -6047,7 +6047,7 @@ proc selnextpage {dir} {
6047
proc unselectline {} {
6048
global selectedline currentid
6049
6050
- catch {unset selectedline}
6050
+ set selectedline {}
6051
catch {unset currentid}
6052
allcanvs delete secsel
6053
rhighlight_none
@@ -6056,7 +6056,7 @@ proc unselectline {} {
6056
proc reselectline {} {
6057
global selectedline
6058
6059
- if {[info exists selectedline]} {
6059
+ if {$selectedline ne {}} {
6060
selectline $selectedline 0
6061
}
6062
}
@@ -6868,7 +6868,7 @@ proc redisplay {} {
6868
setcanvscroll
6869
allcanvs yview moveto [lindex $span 0]
6870
drawvisible
6871
- if {[info exists selectedline]} {
6871
+ if {$selectedline ne {}} {
6872
selectline $selectedline 0
6873
allcanvs yview moveto [lindex $span 0]
6874
}
@@ -7189,8 +7189,7 @@ proc rowmenu {x y id} {
7189
7190
stopfinding
7191
set rowmenuid $id
7192
- if {![info exists selectedline]
7193
- || [rowofcommit $id] eq $selectedline} {
7192
+ if {$selectedline eq {} || [rowofcommit $id] eq $selectedline} {
7193
set state disabled
7194
} else {
7195
set state normal
@@ -7214,7 +7213,7 @@ proc rowmenu {x y id} {
7213
proc diffvssel {dirn} {
7214
global rowmenuid selectedline
7215
7217
- if {![info exists selectedline]} return
7216
+ if {$selectedline eq {}} return
7217
if {$dirn} {
7218
set oldid [commitonrow $selectedline]
7219
set newid $rowmenuid
@@ -9890,6 +9889,7 @@ set viewperm(0) 0
9889
set viewargs(0) {}
9890
set viewargscmd(0) {}
9891
9892
+set selectedline {}
9893
set numcommits 0
9894
set loginstance 0
9895
set cmdlineok 0