From b72bb27cb45f25d1df0d93be17474d8a08715411 Mon Sep 17 00:00:00 2001 From: Aditya Srivastava Date: Thu, 1 Aug 2019 08:27:03 -0700 Subject: [PATCH] select next message when deleting from message viewer --- commands/msg/delete.go | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/commands/msg/delete.go b/commands/msg/delete.go index 55d7f68..06cef9c 100644 --- a/commands/msg/delete.go +++ b/commands/msg/delete.go @@ -43,11 +43,18 @@ func (_ Delete) Execute(aerc *widgets.Aerc, args []string) error { return err } _, isMsgView := widget.(*widgets.MessageViewer) - if isMsgView { - aerc.RemoveTab(widget) - } + mv, _ := aerc.SelectedTab().(*widgets.MessageViewer) store.Next() - acct.Messages().Scroll() + if isMsgView { + nextMsg := store.Selected() + if nextMsg == msg { + aerc.RemoveTab(widget) + acct.Messages().Scroll() + } else { + nextMv := widgets.NewMessageViewer(acct, aerc.Config(), store, nextMsg) + aerc.ReplaceTab(mv, nextMv, nextMsg.Envelope.Subject) + } + } store.Delete([]uint32{msg.Uid}, func(msg types.WorkerMessage) { switch msg := msg.(type) { case *types.Done: