diff options
| author | Bozhidar Batsov <bozhidar@toptal.com> | 2026-04-26 07:49:03 +0100 |
|---|---|---|
| committer | Bozhidar Batsov <bozhidar@toptal.com> | 2026-04-26 07:49:03 +0100 |
| commit | 66b54e9038c8aadf5a515758ca3c0acb03977b0e (patch) | |
| tree | c14a787d0327c548c0921c241e1839c189a5800f /projectile.el | |
| parent | d8e34d08ae8c2344053717b6f21475bd545646f2 (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 'projectile.el')
| -rw-r--r-- | projectile.el | 15 |
1 files changed, 15 insertions, 0 deletions
diff --git a/projectile.el b/projectile.el index a61fcf4..c29d9cf 100644 --- a/projectile.el +++ b/projectile.el @@ -1189,6 +1189,20 @@ argument)." (when (fboundp 'recentf-cleanup) (recentf-cleanup))) +;;;###autoload +(defun projectile-discard-root-cache () + "Clear `projectile-project-root-cache' without touching other caches. +Useful after creating, removing, or moving a project marker (e.g. +`.projectile' or `.git') - Projectile would otherwise keep returning +its previously cached answer for that directory. + +See also `projectile-invalidate-cache', which does this and also drops +the per-project file list and project-type caches." + (interactive) + (setq projectile-project-root-cache (make-hash-table :test 'equal)) + (when projectile-verbose + (message "Cleared Projectile project root cache."))) + (defun projectile-time-seconds () "Return the number of seconds since the unix epoch." (time-convert nil 'integer)) @@ -6698,6 +6712,7 @@ Magit that don't trigger `find-file-hook'." "--" ["Cache current file" projectile-cache-current-file] ["Invalidate cache" projectile-invalidate-cache] + ["Discard project root cache" projectile-discard-root-cache] ["Regenerate [e|g]tags" projectile-regenerate-tags] "--" ["Toggle project wide read-only" projectile-toggle-project-read-only] |
