diff options
author | Jesse Duffield <jessedduffield@gmail.com> | 2021-03-31 22:08:55 +1100 |
---|---|---|
committer | Jesse Duffield <jessedduffield@gmail.com> | 2021-04-02 11:00:15 +1100 |
commit | 332a3c4cbfd263c34d5f53dd971701d2ca69ab4e (patch) | |
tree | 9c2801ce55b7e2bab75fbbaa5dcf82e7d02266ce /pkg/gui/presentation | |
parent | ac41c418092b4561042b52d59b362107a0c2ecd6 (diff) |
file tree for commit files
Diffstat (limited to 'pkg/gui/presentation')
-rw-r--r-- | pkg/gui/presentation/commit_files.go | 44 |
1 files changed, 17 insertions, 27 deletions
diff --git a/pkg/gui/presentation/commit_files.go b/pkg/gui/presentation/commit_files.go index d90e3e990..2e87e61c2 100644 --- a/pkg/gui/presentation/commit_files.go +++ b/pkg/gui/presentation/commit_files.go @@ -8,41 +8,31 @@ import ( "github.com/jesseduffield/lazygit/pkg/utils" ) -func GetCommitFileListDisplayStrings(commitFiles []*models.CommitFile, diffName string) [][]string { - if len(commitFiles) == 0 { - return [][]string{{utils.ColoredString("(none)", color.FgRed)}} - } - - lines := make([][]string, len(commitFiles)) - - for i := range commitFiles { - diffed := commitFiles[i].Name == diffName - lines[i] = getCommitFileDisplayStrings(commitFiles[i], diffed) - } - - return lines -} - -// getCommitFileDisplayStrings returns the display string of branch -func getCommitFileDisplayStrings(f *models.CommitFile, diffed bool) []string { +func GetCommitFileLine(name string, diffName string, commitFile *models.CommitFile) string { yellow := color.New(color.FgYellow) green := color.New(color.FgGreen) defaultColor := color.New(theme.DefaultTextColor) diffTerminalColor := color.New(theme.DiffTerminalColor) - var colour *color.Color - switch f.PatchStatus { - case patch.UNSELECTED: - colour = defaultColor - case patch.WHOLE: - colour = green - case patch.PART: - colour = yellow + if commitFile == nil { + return name } - if diffed { + + colour := defaultColor + if diffName == name { colour = diffTerminalColor + } else if commitFile != nil { + switch commitFile.PatchStatus { + case patch.UNSELECTED: + colour = defaultColor + case patch.WHOLE: + colour = green + case patch.PART: + colour = yellow + } } - return []string{utils.ColoredString(f.ChangeStatus, getColorForChangeStatus(f.ChangeStatus)), colour.Sprint(f.Name)} + + return utils.ColoredString(commitFile.ChangeStatus, getColorForChangeStatus(commitFile.ChangeStatus)) + " " + colour.Sprint(name) } func getColorForChangeStatus(changeStatus string) color.Attribute { |