Skip to content

Commit 94b4a69

Browse files
committed
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>
1 parent 64dc208 commit 94b4a69

1 file changed

Lines changed: 23 additions & 23 deletions

File tree

gitk

Lines changed: 23 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -495,7 +495,7 @@ proc reloadcommits {} {
495495
stop_rev_list $curview
496496
}
497497
resetvarcs $curview
498-
catch {unset selectedline}
498+
set selectedline {}
499499
catch {unset currentid}
500500
catch {unset thickerline}
501501
catch {unset treediffs}
@@ -927,7 +927,7 @@ proc removefakerow {id} {
927927
modify_arc $v $a $i
928928
if {[info exist currentid] && $id eq $currentid} {
929929
unset currentid
930-
unset selectedline
930+
set selectedline {}
931931
}
932932
if {[info exists targetid] && $targetid eq $id} {
933933
set targetid $p
@@ -1838,7 +1838,7 @@ proc makewindow {} {
18381838
pack .tf.bar.rowlabel .tf.bar.rownum .tf.bar.rowlabel2 .tf.bar.numcommits \
18391839
-side left
18401840
global selectedline
1841-
trace add variable selectedline {write unset} selectedline_change
1841+
trace add variable selectedline write selectedline_change
18421842

18431843
# Status label and progress bar
18441844
set statusw .tf.bar.status
@@ -2185,7 +2185,7 @@ proc windows_mousewheel_redirector {W X Y D} {
21852185
proc selectedline_change {n1 n2 op} {
21862186
global selectedline rownumsel
21872187

2188-
if {$op eq "unset"} {
2188+
if {$selectedline eq {}} {
21892189
set rownumsel {}
21902190
} else {
21912191
set rownumsel [expr {$selectedline + 1}]
@@ -3274,7 +3274,7 @@ proc showview {n} {
32743274
set ytop [expr {[lindex $span 0] * $ymax}]
32753275
set ybot [expr {[lindex $span 1] * $ymax}]
32763276
set yscreen [expr {($ybot - $ytop) / 2}]
3277-
if {[info exists selectedline]} {
3277+
if {$selectedline ne {}} {
32783278
set selid $currentid
32793279
set y [yc $selectedline]
32803280
if {$ytop < $y && $y < $ybot} {
@@ -3388,7 +3388,7 @@ proc bolden {row font} {
33883388

33893389
lappend boldrows $row
33903390
$canv itemconf $linehtag($row) -font $font
3391-
if {[info exists selectedline] && $row == $selectedline} {
3391+
if {$row == $selectedline} {
33923392
$canv delete secsel
33933393
set t [eval $canv create rect [$canv bbox $linehtag($row)] \
33943394
-outline {{}} -tags secsel \
@@ -3402,7 +3402,7 @@ proc bolden_name {row font} {
34023402

34033403
lappend boldnamerows $row
34043404
$canv2 itemconf $linentag($row) -font $font
3405-
if {[info exists selectedline] && $row == $selectedline} {
3405+
if {$row == $selectedline} {
34063406
$canv2 delete secsel
34073407
set t [eval $canv2 create rect [$canv2 bbox $linentag($row)] \
34083408
-outline {{}} -tags secsel \
@@ -3831,7 +3831,7 @@ proc askrelhighlight {row id} {
38313831
global descendent highlight_related iddrawn rhighlights
38323832
global selectedline ancestor
38333833

3834-
if {![info exists selectedline]} return
3834+
if {$selectedline eq {}} return
38353835
set isbold 0
38363836
if {$highlight_related eq [mc "Descendant"] ||
38373837
$highlight_related eq [mc "Not descendant"]} {
@@ -4005,7 +4005,7 @@ proc visiblerows {} {
40054005

40064006
proc layoutmore {} {
40074007
global commitidx viewcomplete curview
4008-
global numcommits pending_select selectedline curview
4008+
global numcommits pending_select curview
40094009
global lastscrollset lastscrollrows commitinterest
40104010

40114011
if {$lastscrollrows < 100 || $viewcomplete($curview) ||
@@ -4916,7 +4916,7 @@ proc drawcmittext {id row col} {
49164916
-text $name -font $nfont -tags text]
49174917
set linedtag($row) [$canv3 create text 3 $y -anchor w -fill $fgcolor \
49184918
-text $date -font mainfont -tags text]
4919-
if {[info exists selectedline] && $selectedline == $row} {
4919+
if {$selectedline == $row} {
49204920
make_secsel $row
49214921
}
49224922
set xr [expr {$xt + [font measure $font $headline]}]
@@ -5107,7 +5107,7 @@ proc drawvisible {} {
51075107
if {$endrow >= $vrowmod($curview)} {
51085108
update_arcrows $curview
51095109
}
5110-
if {[info exists selectedline] &&
5110+
if {$selectedline ne {} &&
51115111
$row <= $selectedline && $selectedline <= $endrow} {
51125112
set targetrow $selectedline
51135113
} elseif {[info exists targetid]} {
@@ -5427,7 +5427,7 @@ proc dofind {{dirn 1} {wrap 1}} {
54275427
}
54285428
focus .
54295429
if {$findstring eq {} || $numcommits == 0} return
5430-
if {![info exists selectedline]} {
5430+
if {$selectedline eq {}} {
54315431
set findstartline [lindex [visiblerows] [expr {$dirn < 0}]]
54325432
} else {
54335433
set findstartline $selectedline
@@ -5623,7 +5623,7 @@ proc markmatches {canv l str tag matches font row} {
56235623
[expr {$x0+$xlen+2}] $y1 \
56245624
-outline {} -tags [list match$l matches] -fill yellow]
56255625
$canv lower $t
5626-
if {[info exists selectedline] && $row == $selectedline} {
5626+
if {$row == $selectedline} {
56275627
$canv raise $t secsel
56285628
}
56295629
}
@@ -5782,7 +5782,7 @@ proc appendrefs {pos ids var} {
57825782
proc dispneartags {delay} {
57835783
global selectedline currentid showneartags tagphase
57845784

5785-
if {![info exists selectedline] || !$showneartags} return
5785+
if {$selectedline eq {} || !$showneartags} return
57865786
after cancel dispnexttag
57875787
if {$delay} {
57885788
after 200 dispnexttag
@@ -5796,7 +5796,7 @@ proc dispneartags {delay} {
57965796
proc dispnexttag {} {
57975797
global selectedline currentid showneartags tagphase ctext
57985798

5799-
if {![info exists selectedline] || !$showneartags} return
5799+
if {$selectedline eq {} || !$showneartags} return
58005800
switch -- $tagphase {
58015801
0 {
58025802
set dtags [desctags $currentid]
@@ -6018,7 +6018,7 @@ proc sellastline {} {
60186018
proc selnextline {dir} {
60196019
global selectedline
60206020
focus .
6021-
if {![info exists selectedline]} return
6021+
if {$selectedline eq {}} return
60226022
set l [expr {$selectedline + $dir}]
60236023
unmarkmatches
60246024
selectline $l 1
@@ -6033,7 +6033,7 @@ proc selnextpage {dir} {
60336033
}
60346034
allcanvs yview scroll [expr {$dir * $lpp}] units
60356035
drawvisible
6036-
if {![info exists selectedline]} return
6036+
if {$selectedline eq {}} return
60376037
set l [expr {$selectedline + $dir * $lpp}]
60386038
if {$l < 0} {
60396039
set l 0
@@ -6047,7 +6047,7 @@ proc selnextpage {dir} {
60476047
proc unselectline {} {
60486048
global selectedline currentid
60496049

6050-
catch {unset selectedline}
6050+
set selectedline {}
60516051
catch {unset currentid}
60526052
allcanvs delete secsel
60536053
rhighlight_none
@@ -6056,7 +6056,7 @@ proc unselectline {} {
60566056
proc reselectline {} {
60576057
global selectedline
60586058

6059-
if {[info exists selectedline]} {
6059+
if {$selectedline ne {}} {
60606060
selectline $selectedline 0
60616061
}
60626062
}
@@ -6868,7 +6868,7 @@ proc redisplay {} {
68686868
setcanvscroll
68696869
allcanvs yview moveto [lindex $span 0]
68706870
drawvisible
6871-
if {[info exists selectedline]} {
6871+
if {$selectedline ne {}} {
68726872
selectline $selectedline 0
68736873
allcanvs yview moveto [lindex $span 0]
68746874
}
@@ -7189,8 +7189,7 @@ proc rowmenu {x y id} {
71897189

71907190
stopfinding
71917191
set rowmenuid $id
7192-
if {![info exists selectedline]
7193-
|| [rowofcommit $id] eq $selectedline} {
7192+
if {$selectedline eq {} || [rowofcommit $id] eq $selectedline} {
71947193
set state disabled
71957194
} else {
71967195
set state normal
@@ -7214,7 +7213,7 @@ proc rowmenu {x y id} {
72147213
proc diffvssel {dirn} {
72157214
global rowmenuid selectedline
72167215

7217-
if {![info exists selectedline]} return
7216+
if {$selectedline eq {}} return
72187217
if {$dirn} {
72197218
set oldid [commitonrow $selectedline]
72207219
set newid $rowmenuid
@@ -9890,6 +9889,7 @@ set viewperm(0) 0
98909889
set viewargs(0) {}
98919890
set viewargscmd(0) {}
98929891

9892+
set selectedline {}
98939893
set numcommits 0
98949894
set loginstance 0
98959895
set cmdlineok 0

0 commit comments

Comments
 (0)