Fix crash when no message is selected
Pressing `Enter` on a view that has not yet loaded messages (e.g. at startup) would return `nil` from `Selected()`. Accessing `msg.Uid` on a `nil` reference crashes aerc. This patch moves the `msg == nil` check before accessing `msg.Uid` thus avoiding the crash. To test this patch repeatedly press `Enter` on startup.
This commit is contained in:
parent
31e3e9f56e
commit
abd9e78f02
|
@ -30,8 +30,11 @@ func (ViewMessage) Execute(aerc *widgets.Aerc, args []string) error {
|
|||
}
|
||||
store := acct.Messages().Store()
|
||||
msg := acct.Messages().Selected()
|
||||
if msg == nil {
|
||||
return nil
|
||||
}
|
||||
_, deleted := store.Deleted[msg.Uid]
|
||||
if msg == nil || deleted {
|
||||
if deleted {
|
||||
return nil
|
||||
}
|
||||
viewer := widgets.NewMessageViewer(acct, aerc.Config(), store, msg)
|
||||
|
|
Loading…
Reference in New Issue