gitk: Fixed automatic row selection during load
- Switching views now actually preserves the selected commit. - Reloading (also Edit View) preserves the currently selected commit. - Initial selection does not produce weird scrolling. Signed-off-by: Alexander Gavrilov <angavrilov@gmail.com> Signed-off-by: Paul Mackerras <paulus@samba.org>
Alexander Gavrilov committed
Jul 26, 2008 at 20:13 UTC
567c34e0ed8b9219589a6f1bc102996ac9773776
1 file changed
+24
-17
gitk
+24
-17
@@ -307,7 +307,7 @@ proc start_rev_list {view} {
307
global viewargs viewargscmd viewfiles vfilelimit
308
global showlocalchanges commitinterest
309
global viewactive viewinstances vmergeonly
310
- global pending_select mainheadid
310
+ global mainheadid
311
global vcanopt vflags vrevs vorigargs
312
313
set startmsecs [clock clicks -milliseconds]
@@ -374,9 +374,6 @@ proc start_rev_list {view} {
374
}
375
filerun $fd [list getcommitlines $fd $i $view 0]
376
nowbusy $view [mc "Reading"]
377
- if {$view == $curview} {
378
- set pending_select $mainheadid
379
- }
377
set viewcomplete($view) 0
378
set viewactive($view) 1
379
return 1
@@ -418,11 +415,22 @@ proc stop_rev_list {view} {
415
set viewinstances($view) {}
416
}
417
421
-proc getcommits {} {
418
+proc reset_pending_select {selid} {
419
+ global pending_select mainheadid
420
+
421
+ if {$selid ne {}} {
422
+ set pending_select $selid
423
+ } else {
424
+ set pending_select $mainheadid
425
+ }
426
+}
427
+
428
+proc getcommits {selid} {
429
global canv curview need_redisplay viewactive
430
431
initlayout
432
if {[start_rev_list $curview]} {
433
+ reset_pending_select $selid
434
show_status [mc "Reading commits..."]
435
set need_redisplay 1
436
} else {
@@ -503,7 +511,7 @@ proc updatecommits {} {
511
filerun $fd [list getcommitlines $fd $i $view 1]
512
incr viewactive($view)
513
set viewcomplete($view) 0
506
- set pending_select $mainheadid
514
+ reset_pending_select {}
515
nowbusy $view "Reading"
516
if {$showneartags} {
517
getallcommits
@@ -515,6 +523,11 @@ proc reloadcommits {} {
523
global showneartags treediffs commitinterest cached_commitrow
524
global targetid
525
526
+ set selid {}
527
+ if {$selectedline ne {}} {
528
+ set selid $currentid
529
+ }
530
+
531
if {!$viewcomplete($curview)} {
532
stop_rev_list $curview
533
}
@@ -533,7 +546,7 @@ proc reloadcommits {} {
546
catch {unset cached_commitrow}
547
catch {unset targetid}
548
setcanvscroll
536
- getcommits
549
+ getcommits $selid
550
return 0
551
}
552
@@ -3325,10 +3338,7 @@ proc showview {n} {
3338
3339
run refill_reflist
3340
if {![info exists viewcomplete($n)]} {
3328
- if {$selid ne {}} {
3329
- set pending_select $selid
3330
- }
3331
- getcommits
3341
+ getcommits $selid
3342
return
3343
}
3344
@@ -3365,11 +3375,7 @@ proc showview {n} {
3375
} elseif {$mainheadid ne {} && [commitinview $mainheadid $curview]} {
3376
selectline [rowofcommit $mainheadid] 1
3377
} elseif {!$viewcomplete($n)} {
3368
- if {$selid ne {}} {
3369
- set pending_select $selid
3370
- } else {
3371
- set pending_select $mainheadid
3372
- }
3378
+ reset_pending_select $selid
3379
} else {
3380
set row [first_real_row]
3381
if {$row < $numcommits} {
@@ -4036,6 +4042,7 @@ proc layoutmore {} {
4042
}
4043
if {[info exists pending_select] &&
4044
[commitinview $pending_select $curview]} {
4045
+ update
4046
selectline [rowofcommit $pending_select] 1
4047
}
4048
drawvisible
@@ -9973,4 +9980,4 @@ if {[info exists permviews]} {
9980
addviewmenu $n
9981
}
9982
}
9976
-getcommits
9983
+getcommits {}