diff options
author | Stefan Haller <stefan@haller-berlin.de> | 2024-01-12 13:16:25 +0100 |
---|---|---|
committer | Stefan Haller <stefan@haller-berlin.de> | 2024-01-22 08:40:03 +0100 |
commit | 36134006c52269b1a80f2b42857f008b47db7e6c (patch) | |
tree | f3b7cafa13773bd43ad79465636f1a630d357ff9 /pkg/gui/presentation | |
parent | 321583952402b3e0db9fb74482d63783f186a2d6 (diff) |
Add config setting to suppress showing file icons
Diffstat (limited to 'pkg/gui/presentation')
-rw-r--r-- | pkg/gui/presentation/files.go | 12 | ||||
-rw-r--r-- | pkg/gui/presentation/files_test.go | 4 |
2 files changed, 10 insertions, 6 deletions
diff --git a/pkg/gui/presentation/files.go b/pkg/gui/presentation/files.go index 35fc4616a..5941934c6 100644 --- a/pkg/gui/presentation/files.go +++ b/pkg/gui/presentation/files.go @@ -21,24 +21,26 @@ const ( func RenderFileTree( tree filetree.IFileTree, submoduleConfigs []*models.SubmoduleConfig, + showFileIcons bool, ) []string { collapsedPaths := tree.CollapsedPaths() return renderAux(tree.GetRoot().Raw(), collapsedPaths, -1, -1, func(node *filetree.Node[models.File], treeDepth int, visualDepth int, isCollapsed bool) string { fileNode := filetree.NewFileNode(node) - return getFileLine(isCollapsed, fileNode.GetHasUnstagedChanges(), fileNode.GetHasStagedChanges(), treeDepth, visualDepth, submoduleConfigs, node) + return getFileLine(isCollapsed, fileNode.GetHasUnstagedChanges(), fileNode.GetHasStagedChanges(), treeDepth, visualDepth, showFileIcons, submoduleConfigs, node) }) } func RenderCommitFileTree( tree *filetree.CommitFileTreeViewModel, patchBuilder *patch.PatchBuilder, + showFileIcons bool, ) []string { collapsedPaths := tree.CollapsedPaths() return renderAux(tree.GetRoot().Raw(), collapsedPaths, -1, -1, func(node *filetree.Node[models.CommitFile], treeDepth int, visualDepth int, isCollapsed bool) string { status := commitFilePatchStatus(node, tree, patchBuilder) - return getCommitFileLine(isCollapsed, treeDepth, visualDepth, node, status) + return getCommitFileLine(isCollapsed, treeDepth, visualDepth, node, status, showFileIcons) }) } @@ -109,6 +111,7 @@ func getFileLine( hasStagedChanges bool, treeDepth int, visualDepth int, + showFileIcons bool, submoduleConfigs []*models.SubmoduleConfig, node *filetree.Node[models.File], ) string { @@ -150,7 +153,7 @@ func getFileLine( isLinkedWorktree := file != nil && file.IsWorktree isDirectory := file == nil - if icons.IsIconEnabled() { + if showFileIcons { icon := icons.IconForFile(name, isSubmodule, isLinkedWorktree, isDirectory) paint := color.C256(icon.Color, false) output += paint.Sprint(icon.Icon) + nameColor.Sprint(" ") @@ -189,6 +192,7 @@ func getCommitFileLine( visualDepth int, node *filetree.Node[models.CommitFile], status patch.PatchStatus, + showFileIcons bool, ) string { indentation := strings.Repeat(" ", visualDepth) name := commitFileNameAtDepth(node, treeDepth) @@ -236,7 +240,7 @@ func getCommitFileLine( isSubmodule := false isLinkedWorktree := false - if icons.IsIconEnabled() { + if showFileIcons { icon := icons.IconForFile(name, isSubmodule, isLinkedWorktree, isDirectory) paint := color.C256(icon.Color, false) output += paint.Sprint(icon.Icon) + " " diff --git a/pkg/gui/presentation/files_test.go b/pkg/gui/presentation/files_test.go index b6b543c65..bbaa53947 100644 --- a/pkg/gui/presentation/files_test.go +++ b/pkg/gui/presentation/files_test.go @@ -74,7 +74,7 @@ M file1 for _, path := range s.collapsedPaths { viewModel.ToggleCollapsed(path) } - result := RenderFileTree(viewModel, nil) + result := RenderFileTree(viewModel, nil, false) assert.EqualValues(t, s.expected, result) }) } @@ -141,7 +141,7 @@ M file1 }, ) patchBuilder.Start("from", "to", false, false) - result := RenderCommitFileTree(viewModel, patchBuilder) + result := RenderCommitFileTree(viewModel, patchBuilder, false) assert.EqualValues(t, s.expected, result) }) } |