diff --git a/pkg/gui/filetree/commit_file_manager.go b/pkg/gui/filetree/commit_file_manager.go index 3fd89b63e..e80528bcb 100644 --- a/pkg/gui/filetree/commit_file_manager.go +++ b/pkg/gui/filetree/commit_file_manager.go @@ -89,6 +89,11 @@ func (m *CommitFileManager) ToggleCollapsed(path string) { } func (m *CommitFileManager) Render(diffName string, patchManager *patch.PatchManager) []string { + // can't rely on renderAux to check for nil because an interface won't be nil if its concrete value is nil + if m.tree == nil { + return []string{} + } + return renderAux(m.tree, m.collapsedPaths, "", -1, func(n INode, depth int) string { castN := n.(*CommitFileNode) diff --git a/pkg/gui/filetree/file_manager.go b/pkg/gui/filetree/file_manager.go index 6fd688bc2..2ea9915cc 100644 --- a/pkg/gui/filetree/file_manager.go +++ b/pkg/gui/filetree/file_manager.go @@ -81,6 +81,11 @@ func (m *FileManager) ToggleCollapsed(path string) { } func (m *FileManager) Render(diffName string, submoduleConfigs []*models.SubmoduleConfig) []string { + // can't rely on renderAux to check for nil because an interface won't be nil if its concrete value is nil + if m.tree == nil { + return []string{} + } + return renderAux(m.tree, m.collapsedPaths, "", -1, func(n INode, depth int) string { castN := n.(*FileNode) return presentation.GetFileLine(castN.GetHasUnstagedChanges(), castN.GetHasStagedChanges(), castN.NameAtDepth(depth), diffName, submoduleConfigs, castN.File) diff --git a/pkg/gui/filetree/inode.go b/pkg/gui/filetree/inode.go index 4357f3a8a..cdbc82dcd 100644 --- a/pkg/gui/filetree/inode.go +++ b/pkg/gui/filetree/inode.go @@ -215,9 +215,6 @@ func getLeaves(node INode) []INode { func renderAux(s INode, collapsedPaths CollapsedPaths, prefix string, depth int, renderLine func(INode, int) string) []string { isRoot := depth == -1 - if s == nil { - return []string{} - } renderLineWithPrefix := func() string { return prefix + renderLine(s, depth)