Skip to content

Commit 0375154

Browse files
bertwesargj6t
authored andcommitted
git-gui: fix applying line/ranges when the selection ends at the begin of a line
Selecting also the trailing newline of a line for staging/unstaging would have resulted in also staging/unstaging of the next line. Signed-off-by: Bert Wesarg <bert.wesarg@googlemail.com> Signed-off-by: Johannes Sixt <j6t@kdbg.org>
1 parent 3f851e2 commit 0375154

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

lib/diff.tcl

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -676,7 +676,13 @@ proc apply_or_revert_range_or_line {x y revert} {
676676
}
677677

678678
set first_l [$ui_diff index "$first linestart"]
679-
set last_l [$ui_diff index "$last lineend"]
679+
# don't include the next line if $last points to the start of a line
680+
# ie. <lno>.0
681+
if {[lindex [split $last .] 1] == 0} {
682+
set last_l [$ui_diff index "$last -1 line lineend"]
683+
} else {
684+
set last_l [$ui_diff index "$last lineend"]
685+
}
680686

681687
if {$current_diff_path eq {} || $current_diff_header eq {}} return
682688
if {![lock_index apply_hunk]} return

0 commit comments

Comments
 (0)