From 894668aec26502f0f17b4afff7aa7fc476710a2f Mon Sep 17 00:00:00 2001 From: Tim Culverhouse Date: Sun, 31 Jul 2022 09:41:21 -0500 Subject: [PATCH] archive,move: fix reselect next message Move and Archive used store.Next to select the next message. When moving or archiving multiple messages with an upward movement, this would result in a to-be-removed message being selected. Use findNextNonDeleted function to select the correct next message for these commands. Signed-off-by: Tim Culverhouse Acked-by: Robin Jarry --- commands/msg/archive.go | 6 +++++- commands/msg/move.go | 2 +- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/commands/msg/archive.go b/commands/msg/archive.go index e1ff9a6..c4f06a3 100644 --- a/commands/msg/archive.go +++ b/commands/msg/archive.go @@ -53,9 +53,13 @@ func (Archive) Execute(aerc *widgets.Aerc, args []string) error { return err } archiveDir := acct.AccountConfig().Archive - store.Next() + var uids []uint32 + for _, msg := range msgs { + uids = append(uids, msg.Uid) + } store.ClearVisualMark() acct.Messages().Invalidate() + findNextNonDeleted(uids, store) var uidMap map[string][]uint32 switch args[1] { diff --git a/commands/msg/move.go b/commands/msg/move.go index d88a36f..b42a984 100644 --- a/commands/msg/move.go +++ b/commands/msg/move.go @@ -61,9 +61,9 @@ func (Move) Execute(aerc *widgets.Aerc, args []string) error { if isMsgView { aerc.RemoveTab(h.msgProvider) } - store.Next() store.ClearVisualMark() acct.Messages().Invalidate() + findNextNonDeleted(uids, store) joinedArgs := strings.Join(args[optind:], " ") store.Move(uids, joinedArgs, createParents, func( msg types.WorkerMessage) {