ericdanan / counsel-projectile

Ivy UI for Projectile
286 stars 39 forks source link

`counsel-projectile-switch-project` with a given default action no longer works #160

Closed willbush closed 4 years ago

willbush commented 4 years ago

I think there has been a regression that is causing (counsel-projectile-switch-project "D") to no longer work. It used to correctly take me to dired at the root of the project, but now it's doing the default action of prompting for a buffer to navigate to.

The action "D" corresponds to is still working for me:

(counsel-projectile-switch-project-action-dired "~/system/")

In the :action section of the function counsel-projectile-switch-project When I replace default-action with "D":

(or (and "D"
         (listp counsel-projectile-switch-project-action)
         (integerp (car counsel-projectile-switch-project-action))
         (cons (counsel-projectile--action-index "D" counsel-projectile-switch-project-action)
               (cdr counsel-projectile-switch-project-action)))
    counsel-projectile-switch-project-action)

and evaluate that I get:

(4 ("o" counsel-projectile-switch-project-action "jump to a project buffer or file") ("f" counsel-projectile-switch-project-action-find-file "jump to a project file") ("d" counsel-projectile-switch-project-action-find-dir "jump to a project directory") ("D" counsel-projectile-switch-project-action-dired "open project in dired") ("b" counsel-projectile-switch-project-action-switch-to-buffer "jump to a project buffer") ("m" counsel-projectile-switch-project-action-find-file-manually "find file manually from project root") ("S" counsel-projectile-switch-project-action-save-all-buffers "save all project buffers") ("k" counsel-projectile-switch-project-action-kill-buffers "kill all project buffers") ("K" counsel-projectile-switch-project-action-remove-known-project "remove project from known projects") ("c" counsel-projectile-switch-project-action-compile "run project compilation command") ("C" counsel-projectile-switch-project-action-configure "run project configure command") ...)

If I inline that value and remove everything after index 4, I get the same behavior. However, if I move the desired action to index one it works:

(ivy-read (projectile-prepend-project-name "Switch to project: ")
          (if counsel-projectile-remove-current-project
              (projectile-relevant-known-projects)
            projectile-known-projects)
          :preselect (and (projectile-project-p)
                          (abbreviate-file-name (projectile-project-root)))
          :action '(1 ("D" counsel-projectile-switch-project-action-dired "open project in dired"))
          :require-match t
          :sort counsel-projectile-sort-projects
          :caller 'counsel-projectile-switch-project)

In fact, that index can be anything. It doesn't seem to use it. I'm guessing this is not the format that :action was expecting.

ericdanan commented 4 years ago

This is perhaps related to #159 which was fixed in ivy. Could you update ivy and see if the issue disappears?

MichaelXavier commented 4 years ago

I don't know about OP but this fixed it for me! Thanks!

willbush commented 4 years ago

Updating fixed the issue for me. Thanks!