gitk: Fix file list display when files are renamed
The conversion of the file list to use a text widget assumed incorrectly that the list of files from git-diff-tree -r would correspond 1-1 with the diff sections in the output of git-diff-tree -r -p -C, which is not true when renames are detected. This fixes it by keeping the elements in the difffilestart list in the order they appear in the file list window. Since this means that the elements of difffilestart are no longer necessarily in ascending order, it's somewhat hard to do the dynamic highlighting in the file list as the diff window is scrolled, so I have taken that out for now. Signed-off-by: Paul Mackerras <paulus@samba.org>
This commit is contained in:
parent
da7c24dd9c
commit
89b11d3ba5
91
gitk
91
gitk
@ -512,7 +512,7 @@ proc makewindow {} {
|
|||||||
set ctext .ctop.cdet.left.ctext
|
set ctext .ctop.cdet.left.ctext
|
||||||
text $ctext -bg white -state disabled -font $textfont \
|
text $ctext -bg white -state disabled -font $textfont \
|
||||||
-width $geometry(ctextw) -height $geometry(ctexth) \
|
-width $geometry(ctextw) -height $geometry(ctexth) \
|
||||||
-yscrollcommand scrolltext -wrap none
|
-yscrollcommand {.ctop.cdet.left.sb set} -wrap none
|
||||||
scrollbar .ctop.cdet.left.sb -command "$ctext yview"
|
scrollbar .ctop.cdet.left.sb -command "$ctext yview"
|
||||||
pack .ctop.cdet.left.sb -side right -fill y
|
pack .ctop.cdet.left.sb -side right -fill y
|
||||||
pack $ctext -side left -fill both -expand 1
|
pack $ctext -side left -fill both -expand 1
|
||||||
@ -562,7 +562,8 @@ proc makewindow {} {
|
|||||||
scrollbar .ctop.cdet.right.sb -command "$cflist yview"
|
scrollbar .ctop.cdet.right.sb -command "$cflist yview"
|
||||||
pack .ctop.cdet.right.sb -side right -fill y
|
pack .ctop.cdet.right.sb -side right -fill y
|
||||||
pack $cflist -side left -fill both -expand 1
|
pack $cflist -side left -fill both -expand 1
|
||||||
$cflist tag configure highlight -background yellow
|
$cflist tag configure highlight \
|
||||||
|
-background [$cflist cget -selectbackground]
|
||||||
.ctop.cdet add .ctop.cdet.right
|
.ctop.cdet add .ctop.cdet.right
|
||||||
bind .ctop.cdet <Configure> {resizecdetpanes %W %w}
|
bind .ctop.cdet <Configure> {resizecdetpanes %W %w}
|
||||||
|
|
||||||
@ -1092,14 +1093,13 @@ image create bitmap tri-dn -background black -foreground blue -data {
|
|||||||
}
|
}
|
||||||
|
|
||||||
proc init_flist {first} {
|
proc init_flist {first} {
|
||||||
global cflist cflist_top cflist_bot selectedline difffilestart
|
global cflist cflist_top selectedline difffilestart
|
||||||
|
|
||||||
$cflist conf -state normal
|
$cflist conf -state normal
|
||||||
$cflist delete 0.0 end
|
$cflist delete 0.0 end
|
||||||
if {$first ne {}} {
|
if {$first ne {}} {
|
||||||
$cflist insert end $first
|
$cflist insert end $first
|
||||||
set cflist_top 1
|
set cflist_top 1
|
||||||
set cflist_bot 1
|
|
||||||
$cflist tag add highlight 1.0 "1.0 lineend"
|
$cflist tag add highlight 1.0 "1.0 lineend"
|
||||||
} else {
|
} else {
|
||||||
catch {unset cflist_top}
|
catch {unset cflist_top}
|
||||||
@ -1126,61 +1126,14 @@ proc sel_flist {w x y} {
|
|||||||
if {$cmitmode eq "tree"} return
|
if {$cmitmode eq "tree"} return
|
||||||
if {![info exists cflist_top]} return
|
if {![info exists cflist_top]} return
|
||||||
set l [lindex [split [$w index "@$x,$y"] "."] 0]
|
set l [lindex [split [$w index "@$x,$y"] "."] 0]
|
||||||
|
$cflist tag remove highlight $cflist_top.0 "$cflist_top.0 lineend"
|
||||||
|
$cflist tag add highlight $l.0 "$l.0 lineend"
|
||||||
|
set cflist_top $l
|
||||||
if {$l == 1} {
|
if {$l == 1} {
|
||||||
$ctext yview 1.0
|
$ctext yview 1.0
|
||||||
} else {
|
} else {
|
||||||
catch {$ctext yview [lindex $difffilestart [expr {$l - 2}]]}
|
catch {$ctext yview [lindex $difffilestart [expr {$l - 2}]]}
|
||||||
}
|
}
|
||||||
highlight_flist $l
|
|
||||||
}
|
|
||||||
|
|
||||||
proc scrolltext {f0 f1} {
|
|
||||||
global cflist_top
|
|
||||||
|
|
||||||
.ctop.cdet.left.sb set $f0 $f1
|
|
||||||
if {[info exists cflist_top]} {
|
|
||||||
highlight_flist $cflist_top
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
# Given an index $tl in the $ctext window, this works out which line
|
|
||||||
# of the $cflist window displays the filename whose patch is shown
|
|
||||||
# at the given point in the $ctext window. $ll is a hint about which
|
|
||||||
# line it might be, and is used as the starting point of the search.
|
|
||||||
proc ctext_index {tl ll} {
|
|
||||||
global ctext difffilestart
|
|
||||||
|
|
||||||
while {$ll >= 2 && [$ctext compare $tl < \
|
|
||||||
[lindex $difffilestart [expr {$ll - 2}]]]} {
|
|
||||||
incr ll -1
|
|
||||||
}
|
|
||||||
set nfiles [llength $difffilestart]
|
|
||||||
while {$ll - 1 < $nfiles && [$ctext compare $tl >= \
|
|
||||||
[lindex $difffilestart [expr {$ll - 1}]]]} {
|
|
||||||
incr ll
|
|
||||||
}
|
|
||||||
return $ll
|
|
||||||
}
|
|
||||||
|
|
||||||
proc highlight_flist {ll} {
|
|
||||||
global ctext cflist cflist_top cflist_bot difffilestart
|
|
||||||
|
|
||||||
if {![info exists difffilestart] || [llength $difffilestart] == 0} return
|
|
||||||
set ll [ctext_index [$ctext index @0,1] $ll]
|
|
||||||
set lb $cflist_bot
|
|
||||||
if {$lb < $ll} {
|
|
||||||
set lb $ll
|
|
||||||
}
|
|
||||||
set y [expr {[winfo height $ctext] - 2}]
|
|
||||||
set lb [ctext_index [$ctext index @0,$y] $lb]
|
|
||||||
if {$ll != $cflist_top || $lb != $cflist_bot} {
|
|
||||||
$cflist tag remove highlight $cflist_top.0 "$cflist_bot.0 lineend"
|
|
||||||
for {set l $ll} {$l <= $lb} {incr l} {
|
|
||||||
$cflist tag add highlight $l.0 "$l.0 lineend"
|
|
||||||
}
|
|
||||||
set cflist_top $ll
|
|
||||||
set cflist_bot $lb
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
# Code to implement multiple views
|
# Code to implement multiple views
|
||||||
@ -3561,8 +3514,6 @@ proc getmergediffline {mdf id np} {
|
|||||||
# start of a new file
|
# start of a new file
|
||||||
$ctext insert end "\n"
|
$ctext insert end "\n"
|
||||||
set here [$ctext index "end - 1c"]
|
set here [$ctext index "end - 1c"]
|
||||||
$ctext mark set f:$fname $here
|
|
||||||
$ctext mark gravity f:$fname left
|
|
||||||
lappend difffilestart $here
|
lappend difffilestart $here
|
||||||
add_flist [list $fname]
|
add_flist [list $fname]
|
||||||
set l [expr {(78 - [string length $fname]) / 2}]
|
set l [expr {(78 - [string length $fname]) / 2}]
|
||||||
@ -3693,6 +3644,19 @@ proc getblobdiffs {ids} {
|
|||||||
set nextupdate [expr {[clock clicks -milliseconds] + 100}]
|
set nextupdate [expr {[clock clicks -milliseconds] + 100}]
|
||||||
}
|
}
|
||||||
|
|
||||||
|
proc setinlist {var i val} {
|
||||||
|
global $var
|
||||||
|
|
||||||
|
while {[llength [set $var]] < $i} {
|
||||||
|
lappend $var {}
|
||||||
|
}
|
||||||
|
if {[llength [set $var]] == $i} {
|
||||||
|
lappend $var $val
|
||||||
|
} else {
|
||||||
|
lset $var $i $val
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
proc getblobdiffline {bdf ids} {
|
proc getblobdiffline {bdf ids} {
|
||||||
global diffids blobdifffd ctext curdifftag curtagstart
|
global diffids blobdifffd ctext curdifftag curtagstart
|
||||||
global diffnexthead diffnextnote difffilestart
|
global diffnexthead diffnextnote difffilestart
|
||||||
@ -3719,12 +3683,15 @@ proc getblobdiffline {bdf ids} {
|
|||||||
set here [$ctext index "end - 1c"]
|
set here [$ctext index "end - 1c"]
|
||||||
set curtagstart $here
|
set curtagstart $here
|
||||||
set header $newname
|
set header $newname
|
||||||
lappend difffilestart $here
|
set i [lsearch -exact $treediffs($ids) $fname]
|
||||||
$ctext mark set f:$fname $here
|
if {$i >= 0} {
|
||||||
$ctext mark gravity f:$fname left
|
setinlist difffilestart $i $here
|
||||||
if {$newname != $fname} {
|
}
|
||||||
$ctext mark set f:$newfname $here
|
if {$newname ne $fname} {
|
||||||
$ctext mark gravity f:$newfname left
|
set i [lsearch -exact $treediffs($ids) $newname]
|
||||||
|
if {$i >= 0} {
|
||||||
|
setinlist difffilestart $i $here
|
||||||
|
}
|
||||||
}
|
}
|
||||||
set curdifftag "f:$fname"
|
set curdifftag "f:$fname"
|
||||||
$ctext tag delete $curdifftag
|
$ctext tag delete $curdifftag
|
||||||
|
Loading…
Reference in New Issue
Block a user