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

fix renamed files looking wrong

This commit is contained in:
Jesse Duffield
2021-03-14 13:20:54 +11:00
parent 8288de0c84
commit 058bcddc53
3 changed files with 18 additions and 7 deletions

View File

@ -77,8 +77,19 @@ func (c *GitCommand) GitStatus(opts GitStatusOptions) (string, error) {
return "", err
}
statusLines = strings.Replace(statusLines, "\x00", "\n", -1)
return statusLines, nil
splitLines := strings.Split(statusLines, "\x00")
// if a line starts with 'R' then the next line is the original file.
for i := 0; i < len(splitLines)-1; i++ {
original := splitLines[i]
if strings.HasPrefix(original, "R ") {
next := splitLines[i+1]
updated := "R " + next + models.RENAME_SEPARATOR + strings.TrimPrefix(original, "R ")
splitLines[i] = updated
splitLines = append(splitLines[0:i+1], splitLines[i+2:]...)
}
}
return strings.Join(splitLines, "\n"), nil
}
// MergeStatusFiles merge status files