From ba8892d7e969f89c49d3a261fe50ab6f0e8414d2 Mon Sep 17 00:00:00 2001 From: Henrik Lissner Date: Thu, 30 Apr 2020 19:01:10 -0400 Subject: [PATCH] Fix #3004: stale root cache on project search --- core/autoload/projects.el | 7 +++---- modules/config/default/autoload/search.el | 18 ++++++++++-------- 2 files changed, 13 insertions(+), 12 deletions(-) diff --git a/core/autoload/projects.el b/core/autoload/projects.el index edce48b76..b71623bf6 100644 --- a/core/autoload/projects.el +++ b/core/autoload/projects.el @@ -101,11 +101,10 @@ If DIR is not a project, it will be indexed (but not cached)." (unless (file-readable-p dir) (error "Directory %S isn't readable" dir)) (let* ((default-directory (file-truename (expand-file-name dir))) - (project-root (doom-project-root default-directory)) - (projectile-project-root default-directory) + (projectile-project-root (doom-project-root default-directory)) (projectile-enable-caching projectile-enable-caching)) - (cond ((and project-root (file-equal-p project-root projectile-project-root)) - (unless (doom-project-p projectile-project-root) + (cond ((and projectile-project-root (file-equal-p projectile-project-root default-directory)) + (unless (doom-project-p default-directory) ;; Disable caching if this is not a real project; caching ;; non-projects easily has the potential to inflate the projectile ;; cache beyond reason. diff --git a/modules/config/default/autoload/search.el b/modules/config/default/autoload/search.el index dcd704895..bb3cb2445 100644 --- a/modules/config/default/autoload/search.el +++ b/modules/config/default/autoload/search.el @@ -25,7 +25,8 @@ If prefix ARG is set, prompt for a directory to search from." "Conduct a text search in the current project root. If prefix ARG is set, prompt for a known project to search from." (interactive "P") - (let* ((disabled-command-function nil) + (let* ((projectile-project-root nil) + (disabled-command-function nil) (default-directory (if arg (if-let (projects (projectile-relevant-known-projects)) @@ -51,13 +52,14 @@ If prefix ARG is set, prompt for a known project to search from." (interactive (list (rxt-quote-pcre (or (doom-thing-at-point-or-region) "")) current-prefix-arg)) - (let ((default-directory - (if arg - (if-let (projects (projectile-relevant-known-projects)) - (completing-read "Switch to project: " projects - nil t nil nil (doom-project-root)) - (user-error "There are no known projects")) - default-directory))) + (let* ((projectile-project-root nil) + (default-directory + (if arg + (if-let (projects (projectile-relevant-known-projects)) + (completing-read "Switch to project: " projects + nil t nil nil (doom-project-root)) + (user-error "There are no known projects")) + default-directory))) (cond ((featurep! :completion ivy) (+ivy/project-search nil symbol)) ((featurep! :completion helm)