From 95426c5e46e4e50794740326ae37aedf06062b45 Mon Sep 17 00:00:00 2001 From: Jesse Duffield Date: Mon, 1 Aug 2022 20:32:01 +1000 Subject: [PATCH] handle nil properly with file nodes --- pkg/gui/filetree/commit_file_node.go | 4 ++++ pkg/gui/filetree/file_node.go | 4 ++++ 2 files changed, 8 insertions(+) diff --git a/pkg/gui/filetree/commit_file_node.go b/pkg/gui/filetree/commit_file_node.go index 067eee682..be9868daa 100644 --- a/pkg/gui/filetree/commit_file_node.go +++ b/pkg/gui/filetree/commit_file_node.go @@ -17,5 +17,9 @@ func NewCommitFileNode(node *Node[models.CommitFile]) *CommitFileNode { // returns the underlying node, without any commit-file-specific methods attached func (self *CommitFileNode) Raw() *Node[models.CommitFile] { + if self == nil { + return nil + } + return self.Node } diff --git a/pkg/gui/filetree/file_node.go b/pkg/gui/filetree/file_node.go index 092841b52..2ff707113 100644 --- a/pkg/gui/filetree/file_node.go +++ b/pkg/gui/filetree/file_node.go @@ -19,6 +19,10 @@ func NewFileNode(node *Node[models.File]) *FileNode { // returns the underlying node, without any file-specific methods attached func (self *FileNode) Raw() *Node[models.File] { + if self == nil { + return nil + } + return self.Node }