Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

projectile-project-root's cache doesn't work as it supposed to work #1836

Open
geza-herman opened this issue Mar 27, 2023 · 0 comments
Open

Comments

@geza-herman
Copy link

Expected behavior

Cache should work properly

Actual behavior

Cache doesn't work properly, when the project root exists, but it is found by the non-first entry of projectile-project-root-functions.

Steps to reproduce the problem

The cited part of the code doesn't use the cache properly. The problem is, if a function in projectile-project-root-functions returns nil, then this information will be lost (because there is no differentiation between "cache-entry-doesn't exist yet" and "root-not-found"). For example, suppose that the 3rd function in projectile-project-root-functions finds the root, the 1st and 2nd function returns nil. This means that the result of the 3rd function will be stored properly, but the 1st and 2nd function's result won't. Next time when projectile-project-root is called, it will try the 1st and 2nd function again (because the cache returns nil. That's a problem), and it will use the cached result for the 3rd function (this is right).

       (cl-some
        (lambda (func)
          (let* ((cache-key (format "%s-%s" func dir))
                 (cache-value (gethash cache-key projectile-project-root-cache)))
            (if (and cache-value (file-exists-p cache-value))
                cache-value
              (let ((value (funcall func (file-truename dir))))
                (puthash cache-key value projectile-project-root-cache)
                value))))
        projectile-project-root-functions)

Environment & Version information

Projectile version information

Projectile 20230228.706
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant