Implement next-folder using NextPrev with amount

This fixes ~sircmpwn/aerc2#182

https://todo.sr.ht/~sircmpwn/aerc2/182
This commit is contained in:
Jelle Besseling 2019-08-04 16:05:06 +02:00 committed by Drew DeVault
parent 1f6c108c04
commit 3650b72ca6
3 changed files with 10 additions and 12 deletions

View file

@ -40,12 +40,10 @@ func (_ NextPrevFolder) Execute(aerc *widgets.Aerc, args []string) error {
if acct == nil { if acct == nil {
return errors.New("No account selected") return errors.New("No account selected")
} }
for ; n > 0; n-- {
if args[0] == "prev-folder" { if args[0] == "prev-folder" {
acct.Directories().Prev() acct.Directories().NextPrev(-n)
} else { } else {
acct.Directories().Next() acct.Directories().NextPrev(n)
}
} }
return nil return nil
} }

View file

@ -337,7 +337,7 @@ func (store *MessageStore) Select(index int) {
} }
} }
func (store *MessageStore) nextPrev(delta int) { func (store *MessageStore) NextPrev(delta int) {
uids := store.Uids() uids := store.Uids()
if len(uids) == 0 { if len(uids) == 0 {
return return
@ -361,11 +361,11 @@ func (store *MessageStore) nextPrev(delta int) {
} }
func (store *MessageStore) Next() { func (store *MessageStore) Next() {
store.nextPrev(1) store.NextPrev(1)
} }
func (store *MessageStore) Prev() { func (store *MessageStore) Prev() {
store.nextPrev(-1) store.NextPrev(-1)
} }
func (store *MessageStore) Search(c *imap.SearchCriteria, cb func([]uint32)) { func (store *MessageStore) Search(c *imap.SearchCriteria, cb func([]uint32)) {

View file

@ -136,7 +136,7 @@ func (dirlist *DirectoryList) Draw(ctx *ui.Context) {
} }
} }
func (dirlist *DirectoryList) nextPrev(delta int) { func (dirlist *DirectoryList) NextPrev(delta int) {
curIdx := sort.SearchStrings(dirlist.dirs, dirlist.selected) curIdx := sort.SearchStrings(dirlist.dirs, dirlist.selected)
if curIdx == len(dirlist.dirs) { if curIdx == len(dirlist.dirs) {
return return
@ -152,11 +152,11 @@ func (dirlist *DirectoryList) nextPrev(delta int) {
} }
func (dirlist *DirectoryList) Next() { func (dirlist *DirectoryList) Next() {
dirlist.nextPrev(1) dirlist.NextPrev(1)
} }
func (dirlist *DirectoryList) Prev() { func (dirlist *DirectoryList) Prev() {
dirlist.nextPrev(-1) dirlist.NextPrev(-1)
} }
// filterDirsByFoldersConfig sets dirlist.dirs to the filtered subset of the // filterDirsByFoldersConfig sets dirlist.dirs to the filtered subset of the