summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTim Culverhouse <tim@timculverhouse.com>2022-07-23 21:03:46 -0500
committerRobin Jarry <robin@jarry.cc>2022-07-24 23:05:53 +0200
commit9bfcec56600a20f3e84404e4ddba7d0a5ceecbd9 (patch)
tree5f99de1110a751ca10f183ae024dd7c50c313edc
parent80f8bab6cf01fb3bb2d1c7e8598d67f517617954 (diff)
downloadaerc-9bfcec56600a20f3e84404e4ddba7d0a5ceecbd9.zip
delete: select new last message if last message was deleted
If the last message is deleted, the new selection should be the last message instead of the first message. Fixes: https://todo.sr.ht/~rjarry/aerc/59 Reported-by: Sebastien Binet <s@sbinet.org> Signed-off-by: Tim Culverhouse <tim@timculverhouse.com> Acked-by: Robin Jarry <robin@jarry.cc>
-rw-r--r--commands/msg/delete.go7
1 files changed, 7 insertions, 0 deletions
diff --git a/commands/msg/delete.go b/commands/msg/delete.go
index 7b56a55..2d7ad0f 100644
--- a/commands/msg/delete.go
+++ b/commands/msg/delete.go
@@ -56,6 +56,7 @@ func (Delete) Execute(aerc *widgets.Aerc, args []string) error {
// no more messages in the list
if next == nil {
aerc.RemoveTab(h.msgProvider)
+ store.Select(len(store.Uids()))
acct.Messages().Invalidate()
return
}
@@ -69,6 +70,12 @@ func (Delete) Execute(aerc *widgets.Aerc, args []string) error {
aerc.ReplaceTab(mv, nextMv, next.Envelope.Subject)
})
}
+ } else {
+ if next == nil {
+ // We deleted the last message, select the new last message
+ // instead of the first message
+ store.Select(len(store.Uids()))
+ }
}
acct.Messages().Invalidate()
case *types.Error: