mirror of
https://github.com/jesseduffield/lazygit.git
synced 2025-07-28 16:02:01 +03:00
Improve staging panel integration tests
This commit is contained in:
@ -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)
|
||||
}
|
||||
|
||||
|
@ -134,7 +134,8 @@ func coloredString(textStyle style.TextStyle, str string, selected bool, include
|
||||
}
|
||||
|
||||
func parsePatch(patch string) ([]int, []int, []*PatchLine) {
|
||||
lines := strings.Split(patch, "\n")
|
||||
// ignore trailing newline.
|
||||
lines := strings.Split(strings.TrimSuffix(patch, "\n"), "\n")
|
||||
hunkStarts := []int{}
|
||||
stageableLines := []int{}
|
||||
pastFirstHunkHeader := false
|
||||
@ -179,6 +180,7 @@ func parsePatch(patch string) ([]int, []int, []*PatchLine) {
|
||||
}
|
||||
patchLines[index] = &PatchLine{Kind: lineKind, Content: line}
|
||||
}
|
||||
|
||||
return hunkStarts, stageableLines, patchLines
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user