From 65d43ae472103a847d52f4ae05796ec0d80036d3 Mon Sep 17 00:00:00 2001 From: Henrik Lissner Date: Sun, 30 Mar 2025 15:44:45 -0400 Subject: [PATCH] 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 --- lisp/doom-projects.el | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/lisp/doom-projects.el b/lisp/doom-projects.el index d8441b02a..283f27533 100644 --- a/lisp/doom-projects.el +++ b/lisp/doom-projects.el @@ -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