1
0
mirror of https://github.com/jesseduffield/lazygit.git synced 2025-11-20 17:22:23 +03:00

Fix fixup's false filename detection in hunks containing dashed lines

The existing diff parser incorrectly treated subsequent lines beginning
with "---" as filename headers while processing hunks.  This caused
corruption when dashed lines appeared within diffs themselves.

Restrict filename detection to only occur between hunks.
This commit is contained in:
Anton Bobov
2025-10-31 21:53:57 +05:00
committed by Stefan Haller
parent f4920e8efa
commit 4c4929acad
2 changed files with 21 additions and 1 deletions

View File

@@ -194,7 +194,7 @@ func parseDiff(diff string) ([]*hunk, []*hunk) {
if strings.HasPrefix(line, "diff --git") {
finishHunk()
currentHunk = nil
} else if strings.HasPrefix(line, "--- ") {
} else if currentHunk == nil && strings.HasPrefix(line, "--- ") {
// For some reason, the line ends with a tab character if the file
// name contains spaces
filename = strings.TrimRight(line[6:], "\t")