Skip to content

Commit f4c54b3

Browse files
committed
gitk: Synchronize highlighting in file view for 'f' and 'b' commands
This is based on a patch by Eric Raible <raible@gmail.com>, but does things a bit more simply. Previously, 'b', backspace, and delete all did the same thing. This changes 'b' to perform the inverse of 'f'. And both of them now highlight the filename of the currently diff. This makes it easier to review and navigate the diffs associated with a particular commit using only f, b, and space because the filename of the currently display diff will be dynamically highlighted. Signed-off-by: Paul Mackerras <paulus@samba.org>
1 parent 5e3502d commit f4c54b3

File tree

1 file changed

+25
-7
lines changed

1 file changed

+25
-7
lines changed

gitk

Lines changed: 25 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1016,7 +1016,7 @@ proc makewindow {} {
10161016
bindkey k "selnextline 1"
10171017
bindkey j "goback"
10181018
bindkey l "goforw"
1019-
bindkey b "$ctext yview scroll -1 pages"
1019+
bindkey b prevfile
10201020
bindkey d "$ctext yview scroll 18 units"
10211021
bindkey u "$ctext yview scroll -18 units"
10221022
bindkey / {dofind 1 1}
@@ -5479,26 +5479,44 @@ proc changediffdisp {} {
54795479
$ctext tag conf d1 -elide [lindex $diffelide 1]
54805480
}
54815481

5482+
proc highlightfile {loc cline} {
5483+
global ctext cflist cflist_top
5484+
5485+
$ctext yview $loc
5486+
$cflist tag remove highlight $cflist_top.0 "$cflist_top.0 lineend"
5487+
$cflist tag add highlight $cline.0 "$cline.0 lineend"
5488+
$cflist see $cline.0
5489+
set cflist_top $cline
5490+
}
5491+
54825492
proc prevfile {} {
5483-
global difffilestart ctext
5484-
set prev [lindex $difffilestart 0]
5493+
global difffilestart ctext cmitmode
5494+
5495+
if {$cmitmode eq "tree"} return
5496+
set prev 0.0
5497+
set prevline 1
54855498
set here [$ctext index @0,0]
54865499
foreach loc $difffilestart {
54875500
if {[$ctext compare $loc >= $here]} {
5488-
$ctext yview $prev
5501+
highlightfile $prev $prevline
54895502
return
54905503
}
54915504
set prev $loc
5505+
incr prevline
54925506
}
5493-
$ctext yview $prev
5507+
highlightfile $prev $prevline
54945508
}
54955509

54965510
proc nextfile {} {
5497-
global difffilestart ctext
5511+
global difffilestart ctext cmitmode
5512+
5513+
if {$cmitmode eq "tree"} return
54985514
set here [$ctext index @0,0]
5515+
set line 1
54995516
foreach loc $difffilestart {
5517+
incr line
55005518
if {[$ctext compare $loc > $here]} {
5501-
$ctext yview $loc
5519+
highlightfile $loc $line
55025520
return
55035521
}
55045522
}

0 commit comments

Comments
 (0)