fix: init known projects before projectile-ensure-project

Otherwise, the known projects list could be empty the first time the
project switcher prompt is shown via any command that isn't explicitly
`projectile-switch-project` (like invoking `projectile-find-file` from a
non-project buffer).

Ref: #8330
This commit is contained in:
Henrik Lissner
2025-03-30 15:44:45 -04:00
parent 64c71949f8
commit 65d43ae472

View File

@ -105,6 +105,18 @@ Must end with a slash.")
doom-projectile-cache-dir)))
(funcall fn proot)))
;; HACK: `projectile-ensure-project' operates on the current value of
;; `projectile-known-projects' when prompting the using for a project, which
;; may not have been initialized yet, so do so the first time it is called.
;; REVIEW: PR this upstream
(defadvice! doom--projectile-update-known-projects-a (dir)
:before #'projectile-ensure-project
(unless dir
(when (and (eq projectile-require-project-root 'prompt)
(not projectile-known-projects))
(projectile-known-projects))
(advice-remove 'projectile-ensure-project #'doom--projectile-update-known-projects-a)))
;; Support the more generic .project files as an alternative to .projectile
(defadvice! doom--projectile-dirconfig-file-a ()
:override #'projectile-dirconfig-file