about summary refs log tree commit diff stats
diff options
context:
space:
mode:
authorAditya Srivastava <adityasri163@gmail.com>2019-08-01 08:27:03 -0700
committerDrew DeVault <sir@cmpwn.com>2019-08-02 09:36:41 -0400
commitb72bb27cb45f25d1df0d93be17474d8a08715411 (patch)
treeb79d7163d1f0a583290034b7726f48a60182b356
parentc9a909fee3d79917589f46ebd7c7453afb33bf1c (diff)
downloadaerc-b72bb27cb45f25d1df0d93be17474d8a08715411.tar.gz
select next message when deleting from message viewer
-rw-r--r--commands/msg/delete.go13
1 files changed, 10 insertions, 3 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)
+	mv, _ := aerc.SelectedTab().(*widgets.MessageViewer)
+	store.Next()
 	if isMsgView {
-		aerc.RemoveTab(widget)
+		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.Next()
-	acct.Messages().Scroll()
 	store.Delete([]uint32{msg.Uid}, func(msg types.WorkerMessage) {
 		switch msg := msg.(type) {
 		case *types.Done: