Skip to content

Commit 5e1f235

Browse files
committed
Merge branch 'bw/apply-ends-in-lf' into j6t-testing
* bw/apply-ends-in-lf: git-gui: fix applying line/ranges when the selection ends at the begin of a line
2 parents 2416ad7 + 0375154 commit 5e1f235

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
@@ -650,7 +650,13 @@ proc apply_or_revert_range_or_line {x y revert} {
650650
}
651651

652652
set first_l [$ui_diff index "$first linestart"]
653-
set last_l [$ui_diff index "$last lineend"]
653+
# don't include the next line if $last points to the start of a line
654+
# ie. <lno>.0
655+
if {[lindex [split $last .] 1] == 0} {
656+
set last_l [$ui_diff index "$last -1 line lineend"]
657+
} else {
658+
set last_l [$ui_diff index "$last lineend"]
659+
}
654660

655661
if {$current_diff_path eq {} || $current_diff_header eq {}} return
656662
if {![lock_index apply_hunk]} return

0 commit comments

Comments
 (0)