forgejo/services/gitdiff
silverwind 85bf170ff0
Fix incorrect diff expander for deletion of last lines in a file (#29501)
Fixes: https://github.com/go-gitea/gitea/issues/29498

I don't quite understand this code, but this change does seem to fix the
issue and I tested a number of diffs with it and saw no issue. The
function gets such value if last line is an addition:

```
  LastLeftIdx: (int) 0,
  LastRightIdx: (int) 47,
  LeftIdx: (int) 47,
  RightIdx: (int) 48,
```

If it's a deletion, it gets:

```
  LastLeftIdx: (int) 47,
  LastRightIdx: (int) 0,
  LeftIdx: (int) 48,
  RightIdx: (int) 47,
```

So I think it's correct to make this check respect both left and right
side.

(cherry picked from commit 3b99066aa866e51e6a610716eaddfd1ea3645a67)
2024-03-06 12:10:45 +08:00
..
testdata/academic-module rm .sample hooks which aren't used (#19101) 2022-03-16 10:33:07 +00:00
csv_test.go Even more db.DefaultContext refactor (#27352) 2023-10-03 10:30:41 +00:00
csv.go Use Go 1.21 and update dependencies (#26878) 2023-09-03 10:34:57 +00:00
gitdiff_test.go [BUG] split code conversations in diff tab (#2306) 2024-02-16 12:16:11 +00:00
gitdiff.go Fix incorrect diff expander for deletion of last lines in a file (#29501) 2024-03-06 12:10:45 +08:00
highlightdiff_test.go Implement FSFE REUSE for golang files (#21840) 2022-11-27 18:20:29 +00:00
highlightdiff.go Add option to disable ambiguous unicode characters detection (#28454) 2023-12-17 14:38:54 +00:00
main_test.go make writing main test easier (#27270) 2023-09-28 01:38:53 +00:00