1
0
mirror of https://github.com/jesseduffield/lazygit.git synced 2025-06-17 00:18:05 +02:00

Improve staging panel integration tests

This commit is contained in:
Jesse Duffield
2023-02-24 21:42:27 +11:00
parent 752526c880
commit db011d8e34
18 changed files with 417 additions and 116 deletions

View File

@ -27,7 +27,9 @@ func GetHunksFromDiff(diff string) []*PatchHunk {
var hunkLines []string //nolint:prealloc
pastDiffHeader := false
for lineIdx, line := range strings.SplitAfter(diff, "\n") {
lines := strings.SplitAfter(diff, "\n")
for lineIdx, line := range lines {
isHunkHeader := strings.HasPrefix(line, "@@ -")
if isHunkHeader {
@ -44,6 +46,10 @@ func GetHunksFromDiff(diff string) []*PatchHunk {
continue
}
if lineIdx == len(lines)-1 && line == "" { // skip the trailing newline
continue
}
hunkLines = append(hunkLines, line)
}