summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJesse Duffield <jessedduffield@gmail.com>2019-05-06 22:29:35 +1000
committerJesse Duffield <jessedduffield@gmail.com>2019-05-06 22:39:35 +1000
commit2746b1bd38fa2668490a8db2369dec5146fbaec6 (patch)
treecd224a75125d6527e469a6618c6b8c5e947376fd
parente09aac645035146805a3af0389e1f27fe13599b9 (diff)
Prevent crash when opening in small window
We were crashing when opening lazygit in a small window because the limit view was the only view that got created, and there were two functions that referenced either the 'current' view or the files view, neither of which existed. Now those functions just return nil if the view does not exist
-rw-r--r--pkg/gui/context.go6
-rw-r--r--pkg/gui/files_panel.go4
2 files changed, 9 insertions, 1 deletions
diff --git a/pkg/gui/context.go b/pkg/gui/context.go
index b741132ea..2cdc5c8c6 100644
--- a/pkg/gui/context.go
+++ b/pkg/gui/context.go
@@ -21,7 +21,11 @@ func (gui *Gui) contextTitleMap() map[string]map[string]string {
}
func (gui *Gui) setMainTitle() error {
- currentViewName := gui.g.CurrentView().Name()
+ currentView := gui.g.CurrentView()
+ if currentView == nil {
+ return nil
+ }
+ currentViewName := currentView.Name()
var newTitle string
if context, ok := gui.State.Contexts[currentViewName]; ok {
newTitle = gui.contextTitleMap()[currentViewName][context]
diff --git a/pkg/gui/files_panel.go b/pkg/gui/files_panel.go
index caab1bede..3d2001ac1 100644
--- a/pkg/gui/files_panel.go
+++ b/pkg/gui/files_panel.go
@@ -86,6 +86,10 @@ func (gui *Gui) refreshFiles() error {
selectedFile, _ := gui.getSelectedFile(gui.g)
filesView := gui.getFilesView()
+ if filesView == nil {
+ // if the filesView hasn't been instantiated yet we just return
+ return nil
+ }
if err := gui.refreshStateFiles(); err != nil {
return err
}