gitk: Fix a couple of bugs
insertrow and removerow were trying to adjust rowidlist, rowisopt and rowfinal even if the row where we're inserting/deleting stuff hasn't been laid out yet, which resulted in Tcl errors. This fixes that. Also we weren't deleting the link$linknum tag in appendwithlinks, which resulted in SHA1 IDs in the body of a commit message sometimes getting shown in blue with underlining when they shouldn't. Signed-off-by: Paul Mackerras <paulus@samba.org>
Paul Mackerras committed
Sep 27, 2007 at 10:35 UTC
c73adce219ce52a662d90af1e1762c77ea5c4cb0
1 file changed
+20
-13
gitk
+20
-13
@@ -4027,17 +4027,21 @@ proc insertrow {row newcmit} {
4027
incr commitidx($curview)
4028
set ordertok($curview,$newcmit) $ordertok($curview,$p)
4029
4030
- set idlist [lindex $rowidlist $row]
4031
- if {[llength $kids] == 1} {
4032
- set col [lsearch -exact $idlist $p]
4033
- lset idlist $col $newcmit
4034
- } else {
4035
- set col [llength $idlist]
4036
- lappend idlist $newcmit
4030
+ if {$row < [llength $rowidlist]} {
4031
+ set idlist [lindex $rowidlist $row]
4032
+ if {$idlist ne {}} {
4033
+ if {[llength $kids] == 1} {
4034
+ set col [lsearch -exact $idlist $p]
4035
+ lset idlist $col $newcmit
4036
+ } else {
4037
+ set col [llength $idlist]
4038
+ lappend idlist $newcmit
4039
+ }
4040
+ }
4041
+ set rowidlist [linsert $rowidlist $row $idlist]
4042
+ set rowisopt [linsert $rowisopt $row 0]
4043
+ set rowfinal [linsert $rowfinal $row [lindex $rowfinal $row]]
4044
}
4038
- set rowidlist [linsert $rowidlist $row $idlist]
4039
- set rowisopt [linsert $rowisopt $row 0]
4040
- set rowfinal [linsert $rowfinal $row [lindex $rowfinal $row]]
4045
4046
incr numcommits
4047
@@ -4077,9 +4081,11 @@ proc removerow {row} {
4081
}
4082
incr commitidx($curview) -1
4083
4080
- set rowidlist [lreplace $rowidlist $row $row]
4081
- set rowisopt [lreplace $rowisopt $row $row]
4082
- set rowfinal [lreplace $rowfinal $row $row]
4084
+ if {$row < [llength $rowidlist]} {
4085
+ set rowidlist [lreplace $rowidlist $row $row]
4086
+ set rowisopt [lreplace $rowisopt $row $row]
4087
+ set rowfinal [lreplace $rowfinal $row $row]
4088
+ }
4089
4090
incr numcommits -1
4091
@@ -4443,6 +4449,7 @@ proc appendwithlinks {text tags} {
4449
set e [lindex $l 1]
4450
set linkid [string range $text $s $e]
4451
incr e
4452
+ $ctext tag delete link$linknum
4453
$ctext tag add link$linknum "$start + $s c" "$start + $e c"
4454
setlink $linkid link$linknum
4455
incr linknum