mirror of
				https://github.com/jesseduffield/lazygit.git
				synced 2025-11-04 12:31:43 +03:00 
			
		
		
		
	fix bug caused by interface
This commit is contained in:
		@@ -89,6 +89,11 @@ func (m *CommitFileManager) ToggleCollapsed(path string) {
 | 
				
			|||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
func (m *CommitFileManager) Render(diffName string, patchManager *patch.PatchManager) []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 {
 | 
						return renderAux(m.tree, m.collapsedPaths, "", -1, func(n INode, depth int) string {
 | 
				
			||||||
		castN := n.(*CommitFileNode)
 | 
							castN := n.(*CommitFileNode)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -81,6 +81,11 @@ func (m *FileManager) ToggleCollapsed(path string) {
 | 
				
			|||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
func (m *FileManager) Render(diffName string, submoduleConfigs []*models.SubmoduleConfig) []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 {
 | 
						return renderAux(m.tree, m.collapsedPaths, "", -1, func(n INode, depth int) string {
 | 
				
			||||||
		castN := n.(*FileNode)
 | 
							castN := n.(*FileNode)
 | 
				
			||||||
		return presentation.GetFileLine(castN.GetHasUnstagedChanges(), castN.GetHasStagedChanges(), castN.NameAtDepth(depth), diffName, submoduleConfigs, castN.File)
 | 
							return presentation.GetFileLine(castN.GetHasUnstagedChanges(), castN.GetHasStagedChanges(), castN.NameAtDepth(depth), diffName, submoduleConfigs, castN.File)
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -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 {
 | 
					func renderAux(s INode, collapsedPaths CollapsedPaths, prefix string, depth int, renderLine func(INode, int) string) []string {
 | 
				
			||||||
	isRoot := depth == -1
 | 
						isRoot := depth == -1
 | 
				
			||||||
	if s == nil {
 | 
					 | 
				
			||||||
		return []string{}
 | 
					 | 
				
			||||||
	}
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
	renderLineWithPrefix := func() string {
 | 
						renderLineWithPrefix := func() string {
 | 
				
			||||||
		return prefix + renderLine(s, depth)
 | 
							return prefix + renderLine(s, depth)
 | 
				
			||||||
 
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user