From 61bcd800120c867be81c4cbc592955d0bca4e190 Mon Sep 17 00:00:00 2001 From: Christian Rocha Date: Wed, 3 Jun 2020 12:46:53 -0400 Subject: [PATCH] Don't try and open stuff if there's nothing to open --- ui/stash.go | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/ui/stash.go b/ui/stash.go index 2c76f08..b635012 100644 --- a/ui/stash.go +++ b/ui/stash.go @@ -266,6 +266,10 @@ func stashUpdate(msg tea.Msg, m stashModel) (stashModel, tea.Cmd) { // Open document case "enter": + if len(m.markdowns) == 0 { + break + } + // Load the document from the server. We'll handle the message // that comes back in the main update function. m.state = stashStateLoadingDocument @@ -500,14 +504,14 @@ func stashHelpView(m stashModel) string { } else if m.state == stashStatePromptDelete { h = append(h, "y: delete", "n: cancel") } else { - h = append(h, "enter: open") if len(m.markdowns) > 0 { + h = append(h, "enter: open") h = append(h, "j/k, ↑/↓: choose") } if m.paginator.TotalPages > 1 { h = append(h, "h/l, ←/→: page") } - if !isNews { + if !isNews && len(m.markdowns) > 0 { h = append(h, []string{"x: delete"}...) } h = append(h, []string{"esc: exit"}...)