gitk: Improve the behaviour of the initial selection
It used to be that if you clicked on a line while gitk was still drawing stuff, it would immediately re-select the first line of the display. This fixes that. Signed-off-by: Paul Mackerras <paulus@samba.org>
Paul Mackerras committed
Jun 16, 2007 at 21:51 UTC
e507fd4871acc52cc95934d3d5a6faa04d504ec9
1 file changed
+30
-8
gitk
+30
-8
@@ -1671,7 +1671,7 @@ proc showview {n} {
1671
global pending_select phase
1672
global commitidx rowlaidout rowoptim linesegends
1673
global commfd nextupdate
1674
- global selectedview
1674
+ global selectedview selectfirst
1675
global vparentlist vchildlist vdisporder vcmitlisted
1676
global hlview selectedhlview
1677
@@ -1689,6 +1689,9 @@ proc showview {n} {
1689
} else {
1690
set yscreen [expr {($ybot - $ytop) / 2}]
1691
}
1692
+ } elseif {[info exists pending_select]} {
1693
+ set selid $pending_select
1694
+ unset pending_select
1695
}
1696
unselectline
1697
normalline
@@ -1723,7 +1726,9 @@ proc showview {n} {
1726
.bar.view entryconf Delete* -state [expr {$n == 0? "disabled": "normal"}]
1727
1728
if {![info exists viewdata($n)]} {
1726
- set pending_select $selid
1729
+ if {$selid ne {}} {
1730
+ set pending_select $selid
1731
+ }
1732
getcommits
1733
return
1734
}
@@ -1757,7 +1762,8 @@ proc showview {n} {
1762
set row 0
1763
setcanvscroll
1764
set yf 0
1760
- set row 0
1765
+ set row {}
1766
+ set selectfirst 0
1767
if {$selid ne {} && [info exists commitrow($n,$selid)]} {
1768
set row $commitrow($n,$selid)
1769
# try to get the selected row in the same position on the screen
@@ -1770,7 +1776,17 @@ proc showview {n} {
1776
}
1777
allcanvs yview moveto $yf
1778
drawvisible
1773
- selectline $row 0
1779
+ if {$row ne {}} {
1780
+ selectline $row 0
1781
+ } elseif {$selid ne {}} {
1782
+ set pending_select $selid
1783
+ } else {
1784
+ if {$numcommits > 0} {
1785
+ selectline 0 0
1786
+ } else {
1787
+ set selectfirst 1
1788
+ }
1789
+ }
1790
if {$phase ne {}} {
1791
if {$phase eq "getcommits"} {
1792
show_status "Reading commits..."
@@ -2407,7 +2423,7 @@ proc initlayout {} {
2423
global nextcolor
2424
global parentlist childlist children
2425
global colormap rowtextx
2410
- global linesegends
2426
+ global linesegends selectfirst
2427
2428
set numcommits 0
2429
set displayorder {}
@@ -2427,6 +2443,7 @@ proc initlayout {} {
2443
catch {unset rowtextx}
2444
catch {unset idrowranges}
2445
set linesegends {}
2446
+ set selectfirst 1
2447
}
2448
2449
proc setcanvscroll {} {
@@ -2495,6 +2512,7 @@ proc layoutmore {tmax} {
2512
proc showstuff {canshow} {
2513
global numcommits commitrow pending_select selectedline
2514
global linesegends idrowranges idrangedrawn curview
2515
+ global displayorder selectfirst
2516
2517
if {$numcommits == 0} {
2518
global phase
@@ -2533,8 +2551,13 @@ proc showstuff {canshow} {
2551
$commitrow($curview,$pending_select) < $numcommits} {
2552
selectline $commitrow($curview,$pending_select) 1
2553
}
2536
- if {![info exists selectedline] && ![info exists pending_select]} {
2537
- selectline 0 1
2554
+ if {$selectfirst} {
2555
+ if {[info exists selectedline] || [info exists pending_select]} {
2556
+ set selectfirst 0
2557
+ } else {
2558
+ selectline 0 1
2559
+ set selectfirst 0
2560
+ }
2561
}
2562
}
2563
@@ -3551,7 +3574,6 @@ proc drawrest {} {
3574
global rowlaidout commitidx curview
3575
global pending_select
3576
3554
- set row $rowlaidout
3577
layoutrows $rowlaidout $commitidx($curview) 1
3578
layouttail
3579
optimize_rows $row 0 $commitidx($curview)