From 3ee2ad511eb279a2e5dfaec1b0a69c53c0043b01 Mon Sep 17 00:00:00 2001 From: Jesse Duffield Date: Mon, 1 Aug 2022 22:10:08 +1000 Subject: [PATCH] prevent crash when opening recent repos panel if no recent repos are present --- pkg/gui/recent_repos_panel.go | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/pkg/gui/recent_repos_panel.go b/pkg/gui/recent_repos_panel.go index 3b817fbca..edf3fe393 100644 --- a/pkg/gui/recent_repos_panel.go +++ b/pkg/gui/recent_repos_panel.go @@ -60,8 +60,12 @@ func (gui *Gui) getCurrentBranch(path string) string { } func (gui *Gui) handleCreateRecentReposMenu() error { - // we skip the first one because we're currently in it - recentRepoPaths := gui.c.GetAppState().RecentRepos[1:] + // we'll show an empty panel if there are no recent repos + recentRepoPaths := []string{} + if len(gui.c.GetAppState().RecentRepos) > 0 { + // we skip the first one because we're currently in it + recentRepoPaths = gui.c.GetAppState().RecentRepos[1:] + } currentBranches := sync.Map{}