Skip to content

Commit 567c34e

Browse files
angavrilovpaulusmack
authored andcommitted
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 <[email protected]> Signed-off-by: Paul Mackerras <[email protected]>
1 parent 7272131 commit 567c34e

File tree

1 file changed

+24
-17
lines changed

1 file changed

+24
-17
lines changed

gitk

Lines changed: 24 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -307,7 +307,7 @@ proc start_rev_list {view} {
307307
global viewargs viewargscmd viewfiles vfilelimit
308308
global showlocalchanges commitinterest
309309
global viewactive viewinstances vmergeonly
310-
global pending_select mainheadid
310+
global mainheadid
311311
global vcanopt vflags vrevs vorigargs
312312

313313
set startmsecs [clock clicks -milliseconds]
@@ -374,9 +374,6 @@ proc start_rev_list {view} {
374374
}
375375
filerun $fd [list getcommitlines $fd $i $view 0]
376376
nowbusy $view [mc "Reading"]
377-
if {$view == $curview} {
378-
set pending_select $mainheadid
379-
}
380377
set viewcomplete($view) 0
381378
set viewactive($view) 1
382379
return 1
@@ -418,11 +415,22 @@ proc stop_rev_list {view} {
418415
set viewinstances($view) {}
419416
}
420417

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} {
422429
global canv curview need_redisplay viewactive
423430

424431
initlayout
425432
if {[start_rev_list $curview]} {
433+
reset_pending_select $selid
426434
show_status [mc "Reading commits..."]
427435
set need_redisplay 1
428436
} else {
@@ -503,7 +511,7 @@ proc updatecommits {} {
503511
filerun $fd [list getcommitlines $fd $i $view 1]
504512
incr viewactive($view)
505513
set viewcomplete($view) 0
506-
set pending_select $mainheadid
514+
reset_pending_select {}
507515
nowbusy $view "Reading"
508516
if {$showneartags} {
509517
getallcommits
@@ -515,6 +523,11 @@ proc reloadcommits {} {
515523
global showneartags treediffs commitinterest cached_commitrow
516524
global targetid
517525

526+
set selid {}
527+
if {$selectedline ne {}} {
528+
set selid $currentid
529+
}
530+
518531
if {!$viewcomplete($curview)} {
519532
stop_rev_list $curview
520533
}
@@ -533,7 +546,7 @@ proc reloadcommits {} {
533546
catch {unset cached_commitrow}
534547
catch {unset targetid}
535548
setcanvscroll
536-
getcommits
549+
getcommits $selid
537550
return 0
538551
}
539552

@@ -3325,10 +3338,7 @@ proc showview {n} {
33253338

33263339
run refill_reflist
33273340
if {![info exists viewcomplete($n)]} {
3328-
if {$selid ne {}} {
3329-
set pending_select $selid
3330-
}
3331-
getcommits
3341+
getcommits $selid
33323342
return
33333343
}
33343344

@@ -3365,11 +3375,7 @@ proc showview {n} {
33653375
} elseif {$mainheadid ne {} && [commitinview $mainheadid $curview]} {
33663376
selectline [rowofcommit $mainheadid] 1
33673377
} 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
33733379
} else {
33743380
set row [first_real_row]
33753381
if {$row < $numcommits} {
@@ -4036,6 +4042,7 @@ proc layoutmore {} {
40364042
}
40374043
if {[info exists pending_select] &&
40384044
[commitinview $pending_select $curview]} {
4045+
update
40394046
selectline [rowofcommit $pending_select] 1
40404047
}
40414048
drawvisible
@@ -9973,4 +9980,4 @@ if {[info exists permviews]} {
99739980
addviewmenu $n
99749981
}
99759982
}
9976-
getcommits
9983+
getcommits {}

0 commit comments

Comments
 (0)