mirror of
https://github.com/git/git.git
synced 2024-11-18 05:13:58 +01:00
gitk: Keep the same commits visible as other commits come in
Since commits come in out of order and get sorted as we see them, we can have commits coming in and being placed before the commits that are visible in the graph display pane. Previously we just displayed a certain range of row numbers, meaning that when incoming commits were placed before the displayed range, the displayed commits were displaced downwards. This makes it so that we keep the same set of commits displayed, unless the user explicitly scrolls the pane, in which case it scrolls as expected. We do this by having a "target" commit which we try to keep in the same visible position. If commits have come in before it we scroll the canvases by the number of rows that it has moved in the display order. This also fixes a bug in rowofcommit where it would test cached_commitrow before possibly calling update_arcrows, which is where cached_commitrow gets invalidated if things have changed. Now we call update_arcrows if necessary first. Signed-off-by: Paul Mackerras <paulus@samba.org>
This commit is contained in:
parent
eb5f8c9c00
commit
31c0eaa8cc
57
gitk
57
gitk
@ -734,9 +734,6 @@ proc rowofcommit {id} {
|
||||
global varcid varccommits varcrow curview cached_commitrow
|
||||
global varctok vtokmod
|
||||
|
||||
if {[info exists cached_commitrow($id)]} {
|
||||
return $cached_commitrow($id)
|
||||
}
|
||||
set v $curview
|
||||
if {![info exists varcid($v,$id)]} {
|
||||
puts "oops rowofcommit no arc for [shortids $id]"
|
||||
@ -746,6 +743,9 @@ proc rowofcommit {id} {
|
||||
if {[string compare [lindex $varctok($v) $a] $vtokmod($v)] >= 0} {
|
||||
update_arcrows $v
|
||||
}
|
||||
if {[info exists cached_commitrow($id)]} {
|
||||
return $cached_commitrow($id)
|
||||
}
|
||||
set i [lsearch -exact $varccommits($v,$a) $id]
|
||||
if {$i < 0} {
|
||||
puts "oops didn't find commit [shortids $id] in arc $a"
|
||||
@ -1299,7 +1299,7 @@ proc confirm_popup msg {
|
||||
}
|
||||
|
||||
proc makewindow {} {
|
||||
global canv canv2 canv3 linespc charspc ctext cflist
|
||||
global canv canv2 canv3 linespc charspc ctext cflist cscroll
|
||||
global tabstop
|
||||
global findtype findtypemenu findloc findstring fstring geometry
|
||||
global entries sha1entry sha1string sha1but
|
||||
@ -1774,7 +1774,7 @@ proc canvscan {op w x y} {
|
||||
|
||||
proc scrollcanv {cscroll f0 f1} {
|
||||
$cscroll set $f0 $f1
|
||||
drawfrac $f0 $f1
|
||||
drawvisible
|
||||
flushhighlights
|
||||
}
|
||||
|
||||
@ -4538,21 +4538,50 @@ proc undolayout {row} {
|
||||
}
|
||||
}
|
||||
|
||||
proc drawfrac {f0 f1} {
|
||||
global canv linespc
|
||||
proc drawvisible {} {
|
||||
global canv linespc curview vrowmod selectedline targetrow targetid
|
||||
global need_redisplay cscroll
|
||||
|
||||
set fs [$canv yview]
|
||||
set ymax [lindex [$canv cget -scrollregion] 3]
|
||||
if {$ymax eq {} || $ymax == 0} return
|
||||
set f0 [lindex $fs 0]
|
||||
set f1 [lindex $fs 1]
|
||||
set y0 [expr {int($f0 * $ymax)}]
|
||||
set row [expr {int(($y0 - 3) / $linespc) - 1}]
|
||||
set y1 [expr {int($f1 * $ymax)}]
|
||||
set endrow [expr {int(($y1 - 3) / $linespc) + 1}]
|
||||
drawcommits $row $endrow
|
||||
}
|
||||
|
||||
proc drawvisible {} {
|
||||
global canv
|
||||
eval drawfrac [$canv yview]
|
||||
if {[info exists targetid]} {
|
||||
set r [rowofcommit $targetid]
|
||||
if {$r != $targetrow} {
|
||||
# Fix up the scrollregion and change the scrolling position
|
||||
# now that our target row has moved.
|
||||
set diff [expr {($r - $targetrow) * $linespc}]
|
||||
set targetrow $r
|
||||
setcanvscroll
|
||||
set ymax [lindex [$canv cget -scrollregion] 3]
|
||||
incr y0 $diff
|
||||
incr y1 $diff
|
||||
set f0 [expr {$y0 / $ymax}]
|
||||
set f1 [expr {$y1 / $ymax}]
|
||||
allcanvs yview moveto $f0
|
||||
$cscroll set $f0 $f1
|
||||
set need_redisplay 1
|
||||
}
|
||||
}
|
||||
|
||||
set row [expr {int(($y0 - 3) / $linespc) - 1}]
|
||||
set endrow [expr {int(($y1 - 3) / $linespc) + 1}]
|
||||
if {$endrow >= $vrowmod($curview)} {
|
||||
update_arcrows $curview
|
||||
}
|
||||
if {[info exists selectedline] &&
|
||||
$row <= $selectedline && $selectedline <= $endrow} {
|
||||
set targetrow $selectedline
|
||||
} else {
|
||||
set targetrow [expr {int(($row + $endrow) / 2)}]
|
||||
}
|
||||
set targetid [commitonrow $targetrow]
|
||||
drawcommits $row $endrow
|
||||
}
|
||||
|
||||
proc clear_display {} {
|
||||
|
Loading…
Reference in New Issue
Block a user