diff options
author | Daniel Bridges <bridges2@gmail.com> | 2019-07-09 17:04:21 -0700 |
---|---|---|
committer | Drew DeVault <sir@cmpwn.com> | 2019-07-10 13:21:38 -0400 |
commit | 217e85a55d0c1047bef1e2bc41783ccd4629bfc1 (patch) | |
tree | 5e06a60ccc27e59e4eef63315cea5065b5c3e8c6 /widgets/account.go | |
parent | 3f30c27bb31f26ca639b7a87d54a7c522bbe8be0 (diff) | |
download | aerc-217e85a55d0c1047bef1e2bc41783ccd4629bfc1.tar.gz |
Fix crashes when operating on empty folder (#216)
Diffstat (limited to 'widgets/account.go')
-rw-r--r-- | widgets/account.go | 8 |
1 files changed, 6 insertions, 2 deletions
diff --git a/widgets/account.go b/widgets/account.go index e08a2537..981a143a 100644 --- a/widgets/account.go +++ b/widgets/account.go @@ -1,6 +1,7 @@ package widgets import ( + "errors" "fmt" "log" @@ -170,8 +171,11 @@ func (acct *AccountView) SelectedAccount() *AccountView { return acct } -func (acct *AccountView) SelectedMessage() *models.MessageInfo { - return acct.msglist.Selected() +func (acct *AccountView) SelectedMessage() (*models.MessageInfo, error) { + if len(acct.msglist.Store().Uids) == 0 { + return nil, errors.New("no message selected") + } + return acct.msglist.Selected(), nil } func (acct *AccountView) SelectedMessagePart() *PartInfo { |