Fix #3004: stale root cache on project search

This commit is contained in:
Henrik Lissner 2020-04-30 19:01:10 -04:00
parent f7655de598
commit ba8892d7e9
No known key found for this signature in database
GPG key ID: 5F6C0EA160557395
2 changed files with 13 additions and 12 deletions

View file

@ -101,11 +101,10 @@ If DIR is not a project, it will be indexed (but not cached)."
(unless (file-readable-p dir) (unless (file-readable-p dir)
(error "Directory %S isn't readable" dir)) (error "Directory %S isn't readable" dir))
(let* ((default-directory (file-truename (expand-file-name dir))) (let* ((default-directory (file-truename (expand-file-name dir)))
(project-root (doom-project-root default-directory)) (projectile-project-root (doom-project-root default-directory))
(projectile-project-root default-directory)
(projectile-enable-caching projectile-enable-caching)) (projectile-enable-caching projectile-enable-caching))
(cond ((and project-root (file-equal-p project-root projectile-project-root)) (cond ((and projectile-project-root (file-equal-p projectile-project-root default-directory))
(unless (doom-project-p projectile-project-root) (unless (doom-project-p default-directory)
;; Disable caching if this is not a real project; caching ;; Disable caching if this is not a real project; caching
;; non-projects easily has the potential to inflate the projectile ;; non-projects easily has the potential to inflate the projectile
;; cache beyond reason. ;; cache beyond reason.

View file

@ -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. "Conduct a text search in the current project root.
If prefix ARG is set, prompt for a known project to search from." If prefix ARG is set, prompt for a known project to search from."
(interactive "P") (interactive "P")
(let* ((disabled-command-function nil) (let* ((projectile-project-root nil)
(disabled-command-function nil)
(default-directory (default-directory
(if arg (if arg
(if-let (projects (projectile-relevant-known-projects)) (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 (interactive
(list (rxt-quote-pcre (or (doom-thing-at-point-or-region) "")) (list (rxt-quote-pcre (or (doom-thing-at-point-or-region) ""))
current-prefix-arg)) current-prefix-arg))
(let ((default-directory (let* ((projectile-project-root nil)
(if arg (default-directory
(if-let (projects (projectile-relevant-known-projects)) (if arg
(completing-read "Switch to project: " projects (if-let (projects (projectile-relevant-known-projects))
nil t nil nil (doom-project-root)) (completing-read "Switch to project: " projects
(user-error "There are no known projects")) nil t nil nil (doom-project-root))
default-directory))) (user-error "There are no known projects"))
default-directory)))
(cond ((featurep! :completion ivy) (cond ((featurep! :completion ivy)
(+ivy/project-search nil symbol)) (+ivy/project-search nil symbol))
((featurep! :completion helm) ((featurep! :completion helm)