aboutsummaryrefslogtreecommitdiffstats
path: root/commands/msg
diff options
context:
space:
mode:
authorKoni Marti <koni.marti@gmail.com>2022-08-12 23:15:43 +0200
committerRobin Jarry <robin@jarry.cc>2022-08-22 10:04:12 +0200
commit45e506e6aebdfdcb743d2d861eaddb85a01b3d5b (patch)
treed1eed2057c63c24177142efef514ad650875954f /commands/msg
parent588be1a28422a6c431f11f820af73e99f11342c6 (diff)
downloadaerc-45e506e6aebdfdcb743d2d861eaddb85a01b3d5b.tar.gz
delete: fix find-next function
Fixes the find-next-loop when deleting the last message. The reverse loop with store.Prev() will break too early because the value of 'previous' was not reset correctly. Fixes: d941960f "delete: improve find next function" References: https://todo.sr.ht/~rjarry/aerc/59 Signed-off-by: Koni Marti <koni.marti@gmail.com> Tested-by: Tim Culverhouse <tim@timculverhouse.com>
Diffstat (limited to 'commands/msg')
-rw-r--r--commands/msg/delete.go9
1 files changed, 6 insertions, 3 deletions
diff --git a/commands/msg/delete.go b/commands/msg/delete.go
index 9db850ec..ee682a47 100644
--- a/commands/msg/delete.go
+++ b/commands/msg/delete.go
@@ -59,7 +59,7 @@ func (Delete) Execute(aerc *widgets.Aerc, args []string) error {
// no more messages in the list
if next == nil {
aerc.RemoveTab(h.msgProvider)
- acct.Messages().Select(0)
+ acct.Messages().Select(-1)
acct.Messages().Invalidate()
return
}
@@ -77,7 +77,7 @@ func (Delete) Execute(aerc *widgets.Aerc, args []string) error {
if next == nil {
// We deleted the last message, select the new last message
// instead of the first message
- acct.Messages().Select(0)
+ acct.Messages().Select(-1)
}
}
case *types.Error:
@@ -98,10 +98,13 @@ func findNextNonDeleted(deleted []uint32, store *lib.MessageStore) *models.Messa
var next, previous *models.MessageInfo
stepper := []func(){store.Next, store.Prev}
for _, stepFn := range stepper {
+ previous = nil
for {
next = store.Selected()
if next != nil && !contains(deleted, next.Uid) {
- return next
+ if _, deleted := store.Deleted[next.Uid]; !deleted {
+ return next
+ }
}
if next == nil || previous == next {
break