aboutsummaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorBozhidar Batsov <bozhidar@toptal.com>2026-04-26 07:49:03 +0100
committerBozhidar Batsov <bozhidar@toptal.com>2026-04-26 07:49:03 +0100
commit66b54e9038c8aadf5a515758ca3c0acb03977b0e (patch)
treec14a787d0327c548c0921c241e1839c189a5800f /test
parentd8e34d08ae8c2344053717b6f21475bd545646f2 (diff)
Add projectile-discard-root-cache command (#1936)
The existing projectile-invalidate-cache always tries to also clear the per-project files cache, which means it either prompts for a project (with prefix arg) or only operates when you're already in a project. Users who just created a marker file in a directory that Projectile previously considered rootless ended up picking an unrelated project from the prompt just to get the root cache flushed. projectile-discard-root-cache is a focused alternative that empties projectile-project-root-cache only. Wired into the menu next to the existing 'Invalidate cache' entry; deliberately not bound on the prefix map since the keymap is already dense.
Diffstat (limited to 'test')
-rw-r--r--test/projectile-test.el17
1 files changed, 17 insertions, 0 deletions
diff --git a/test/projectile-test.el b/test/projectile-test.el
index 600e137..4d56d4d 100644
--- a/test/projectile-test.el
+++ b/test/projectile-test.el
@@ -1406,6 +1406,23 @@ Just delegates OPERATION and ARGS for all operations except for`shell-command`'.
(spy-on 'projectile-project-root :and-return-value nil)
(expect (projectile-acquire-root) :to-equal "/here/"))))
+(describe "projectile-discard-root-cache"
+ (it "empties the root cache without touching other caches"
+ (let ((projectile-project-root-cache (make-hash-table :test 'equal))
+ (projectile-projects-cache (make-hash-table :test 'equal))
+ (projectile-project-type-cache (make-hash-table :test 'equal))
+ (projectile-verbose nil))
+ (puthash (cons 'projectile-root-bottom-up "/x/") "/x/"
+ projectile-project-root-cache)
+ (puthash (cons 'none "/y/") 'none projectile-project-root-cache)
+ (puthash "/x/" '("a" "b") projectile-projects-cache)
+ (puthash "/x/" 'emacs-eldev projectile-project-type-cache)
+ (projectile-discard-root-cache)
+ (expect (hash-table-count projectile-project-root-cache) :to-equal 0)
+ ;; Other caches must be untouched.
+ (expect (gethash "/x/" projectile-projects-cache) :to-equal '("a" "b"))
+ (expect (gethash "/x/" projectile-project-type-cache) :to-equal 'emacs-eldev))))
+
(describe "projectile-file-exists-p"
(it "returns t if file exists"
(projectile-test-with-sandbox