bbatsov / helm-projectile

Helm UI for Projectile
327 stars 71 forks source link

`helm-source-projectile-buffer` omits first (the current) buffer from the list of buffers #160

Open dvdkhlng opened 2 years ago

dvdkhlng commented 2 years ago

Expected behavior

Running helm-projectile, I expected all project buffers to be shown, because I wanted to select them all to run a multi-file replace.

Actual behavior

helm-projectile (and also helm-projectile-switch-to-buffer) omits the current buffer from the list. This may make sense when switching buffers, but it makes it impossible to select all of the project's currently opened files for stuff like bulk search&replace.

The questionable code in question is:

(setq helm-projectile-buffers-list-cache
                           (ignore-errors (cdr (projectile-project-buffer-names))))

Steps to reproduce the problem

M-x helm-projectile

Environment & version information

Workaround

The following workaround is unclean and has many unwanted side-effects but it seems to fix the problem in question for me:

(defadvice projectile-project-buffer-names (after helm-projectile-patch-dummy
                                                  activate)
  "Ugly fix.
`helm-source-projectile-buffer' does `cdr' on
`projectile-project-buffer-names'.  Undo that here.
Unfortunately this will interfere with other projectile
functionns?"
  (setq ad-return-value (cons "*scratch*" ad-return-value)))