diff options
author | Jesse Duffield <jessedduffield@gmail.com> | 2021-03-31 23:00:24 +1100 |
---|---|---|
committer | Jesse Duffield <jessedduffield@gmail.com> | 2021-04-02 11:00:15 +1100 |
commit | 50c169e0a30597c4e1da85f2e1b9b27958dfe5a6 (patch) | |
tree | 0a0606d6c9e0884e0cc8e4407d0b527fbb9dc8ce /pkg/gui/filetree | |
parent | 7364525bf5ae7b6b4ff8f0e4381e1014726219ad (diff) |
better colouring for directories for when adding a patch
Diffstat (limited to 'pkg/gui/filetree')
-rw-r--r-- | pkg/gui/filetree/commit_file_change_manager.go | 20 |
1 files changed, 19 insertions, 1 deletions
diff --git a/pkg/gui/filetree/commit_file_change_manager.go b/pkg/gui/filetree/commit_file_change_manager.go index 48754e5de..ee05ca3b9 100644 --- a/pkg/gui/filetree/commit_file_change_manager.go +++ b/pkg/gui/filetree/commit_file_change_manager.go @@ -91,6 +91,24 @@ func (m *CommitFileChangeManager) ToggleCollapsed(path string) { func (m *CommitFileChangeManager) Render(diffName string, patchManager *patch.PatchManager) []string { return renderAux(m.tree, m.collapsedPaths, "", -1, func(n INode, depth int) string { castN := n.(*CommitFileChangeNode) - return presentation.GetCommitFileLine(castN.NameAtDepth(depth), diffName, castN.File, patchManager, m.parent) + + // This is a little convoluted because we're dealing with either a leaf or a non-leaf. + // But this code actually applies to both. If it's a leaf, the status will just + // be whatever status it is, but if it's a non-leaf it will determine its status + // based on the leaves of that subtree + var status patch.PatchStatus + if castN.EveryFile(func(file *models.CommitFile) bool { + return patchManager.GetFileStatus(file.Name, m.parent) == patch.WHOLE + }) { + status = patch.WHOLE + } else if castN.EveryFile(func(file *models.CommitFile) bool { + return patchManager.GetFileStatus(file.Name, m.parent) == patch.UNSELECTED + }) { + status = patch.UNSELECTED + } else { + status = patch.PART + } + + return presentation.GetCommitFileLine(castN.NameAtDepth(depth), diffName, castN.File, status) }) } |