diff options
Diffstat (limited to 'git-gui/git-gui.sh')
-rwxr-xr-x | git-gui/git-gui.sh | 27 |
1 files changed, 26 insertions, 1 deletions
diff --git a/git-gui/git-gui.sh b/git-gui/git-gui.sh index ed24aa9d2f..91c00e6489 100755 --- a/git-gui/git-gui.sh +++ b/git-gui/git-gui.sh @@ -2501,9 +2501,28 @@ proc toggle_or_diff {mode w args} { set pos [split [$w index @$x,$y] .] foreach {lno col} $pos break } else { + if {$mode eq "toggle"} { + if {$w eq $ui_workdir} { + do_add_selection + set last_clicked {} + return + } + if {$w eq $ui_index} { + do_unstage_selection + set last_clicked {} + return + } + } + if {$last_clicked ne {}} { set lno [lindex $last_clicked 1] } else { + if {![info exists file_lists] + || ![info exists file_lists($w)] + || [llength $file_lists($w)] == 0} { + set last_clicked {} + return + } set lno [expr {int([lindex [$w tag ranges in_diff] 0])}] } if {$mode eq "toggle"} { @@ -2514,7 +2533,13 @@ proc toggle_or_diff {mode w args} { } } - set path [lindex $file_lists($w) [expr {$lno - 1}]] + if {![info exists file_lists] + || ![info exists file_lists($w)] + || [llength $file_lists($w)] < $lno - 1} { + set path {} + } else { + set path [lindex $file_lists($w) [expr {$lno - 1}]] + } if {$path eq {}} { set last_clicked {} return |