From 37ddad48770fe5e2f98c03bfc4692a59cd6d4a16 Mon Sep 17 00:00:00 2001 From: Robin Jarry Date: Mon, 24 Jun 2024 22:10:57 +0200 Subject: next,prev: fix panic when message list is empty When running :filter -u and iterating over all messages with maildir, the list will eventually become empty (e.g. all messages have been read, no unread messages can be displayed). At this point, :next or :prev will fail to select anything and the maildir backend will return an error. Since the error is not caught, the message viewer is reloaded with a broken message. At this point, any key press causes a panic. This only happens with maildir because message list filters are updated dynamically in the background everytime a filsystem event is triggered. Avoid reloading the message viewer if an error is returned by the backend. Just display the error and abort. Link: https://lists.sr.ht/~rjarry/aerc-devel/%3CD1761AO8LJUL.12698V9VQDR9B@gmail.com%3E Reported-by: Matthew Bystrin Signed-off-by: Robin Jarry Tested-by: Koni Marti --- commands/account/next.go | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/commands/account/next.go b/commands/account/next.go index 4245dd60..e14b14fb 100644 --- a/commands/account/next.go +++ b/commands/account/next.go @@ -66,6 +66,10 @@ func (np NextPrevMsg) Execute(args []string) error { if mv, ok := app.SelectedTabContent().(*app.MessageViewer); ok { reloadViewer := func(nextMsg *models.MessageInfo) { + if nextMsg.Error != nil { + app.PushError(nextMsg.Error.Error()) + return + } lib.NewMessageStoreView(nextMsg, mv.MessageView().SeenFlagSet(), store, app.CryptoProvider(), app.DecryptKeys, func(view lib.MessageView, err error) { -- cgit