Advance cursor after :delete and :move

So that you can repeat the action on the next message if appropriate
This commit is contained in:
Drew DeVault 2019-05-19 18:21:02 -04:00
parent f9251c2344
commit fa5d8d7a00
3 changed files with 7 additions and 4 deletions

View File

@ -24,6 +24,7 @@ func DeleteMessage(aerc *widgets.Aerc, args []string) error {
} }
store := acct.Messages().Store() store := acct.Messages().Store()
msg := acct.Messages().Selected() msg := acct.Messages().Selected()
acct.Messages().Next()
store.Delete([]uint32{msg.Uid}, func(msg types.WorkerMessage) { store.Delete([]uint32{msg.Uid}, func(msg types.WorkerMessage) {
switch msg := msg.(type) { switch msg := msg.(type) {
case *types.Done: case *types.Done:

View File

@ -25,6 +25,7 @@ func Move(aerc *widgets.Aerc, args []string) error {
} }
msg := acct.Messages().Selected() msg := acct.Messages().Selected()
store := acct.Messages().Store() store := acct.Messages().Store()
acct.Messages().Next()
store.Move([]uint32{msg.Uid}, args[1], func(msg types.WorkerMessage) { store.Move([]uint32{msg.Uid}, args[1], func(msg types.WorkerMessage) {
switch msg := msg.(type) { switch msg := msg.(type) {
case *types.Done: case *types.Done:

View File

@ -109,10 +109,6 @@ func (ml *MessageList) storeUpdate(store *lib.MessageStore) {
} }
if len(store.Uids) > 0 { if len(store.Uids) > 0 {
// Prevent selecting beyond the last message
for ml.selected >= len(store.Uids) {
ml.Prev()
}
// When new messages come in, advance the cursor accordingly // When new messages come in, advance the cursor accordingly
// Note that this assumes new messages are appended to the top, which // Note that this assumes new messages are appended to the top, which
// isn't necessarily true once we implement SORT... ideally we'd look // isn't necessarily true once we implement SORT... ideally we'd look
@ -122,6 +118,11 @@ func (ml *MessageList) storeUpdate(store *lib.MessageStore) {
ml.Next() ml.Next()
} }
} }
if len(store.Uids) < ml.nmsgs && ml.nmsgs != 0 {
for i := 0; i < ml.nmsgs-len(store.Uids); i++ {
ml.Prev()
}
}
ml.nmsgs = len(store.Uids) ml.nmsgs = len(store.Uids)
} }