~sircmpwn/aerc2#182:
:next-folder n only moves one folder

I'm on MacOS in case that makes a difference.

To reproduce the issue simply type :next-folder 2 once you've opened the app and only one folder will be moved.

Status
REPORTED
Submitter
~ake
Assigned to
No-one
Submitted
5 months ago
Updated
5 months ago
Labels
No labels applied.

~ake 5 months ago

A simple fix for this is to expose dirlist.nextPrev and use that instead:

diff --git a/commands/account/next-folder.go b/commands/account/next-folder.go
index 6ad3d54..e1c9152 100644
--- a/commands/account/next-folder.go
+++ b/commands/account/next-folder.go
@@ -35,12 +35,10 @@ func NextPrevFolder(aerc *widgets.Aerc, args []string) error {
        if acct == nil {
                return errors.New("No account selected")
        }
-       for ; n > 0; n-- {
-               if args[0] == "prev-folder" {
-                       acct.Directories().Prev()
-               } else {
-                       acct.Directories().Next()
-               }
+       if args[0] == "prev-folder" {
+               acct.Directories().NextPrev(-n)
+       } else {
+               acct.Directories().NextPrev(n)
        }
        return nil
 }
diff --git a/widgets/dirlist.go b/widgets/dirlist.go
index 1240e56..f40c796 100644
--- a/widgets/dirlist.go
+++ b/widgets/dirlist.go
@@ -122,7 +122,7 @@ func (dirlist *DirectoryList) Draw(ctx *ui.Context) {
        }
 }

-func (dirlist *DirectoryList) nextPrev(delta int) {
+func (dirlist *DirectoryList) NextPrev(delta int) {
        for i, dir := range dirlist.dirs {
                if dir == dirlist.selected {
                        var j int
@@ -152,9 +152,9 @@ func (dirlist *DirectoryList) nextPrev(delta int) {
 }

 func (dirlist *DirectoryList) Next() {
-       dirlist.nextPrev(1)
+       dirlist.NextPrev(1)
 }

 func (dirlist *DirectoryList) Prev() {
-       dirlist.nextPrev(-1)
+       dirlist.NextPrev(-1)
 }

But this makes dirlist.Next and dirlist.Prev obsolete and doesn't match msglist, but maybe that should change too?

Register here or Log in to comment, or comment via email.