Invalidate projectile-project-root-cache
I find that a frequent operation is:
- Attempt to
projectile-find-file - Realize my current directory is not marked as a project
- Create
.projectilefile - Attempt to
projectile-find-fileagain - To my surprise, Projectile still thinks the directory is not marked as a project, even though it is
- Attempt to use
projectile-invalidate-cache - To my further surprise, Projectile forces me to select a project to clear the cache for, even though what I need is just to clear
projectile-project-root-cache, which is not associated with any project - Select an unrelated project to clear the cache for, which clears
projectile-project-root-cacheas a side effect - Now
projectile-find-fileworks
Suggestions for improvement:
- Detect cases where
projectile-project-root-cacheshould be cleared automatically to avoid user confusion - Add a user command for clearing
projectile-project-root-cachewithout needing to select a project - Document the fact that this cache exists (since it affects user-visible behavior)
I could help out with this, but creating an issue first for discussion.
All good suggestions. PR welcome!
Btw, does an empty cache get created in this case when there's no project? (this definitely is a bug if so)
The nil return value of the entry in projectile-project-root-functions is cached if no project is detected:
https://github.com/bbatsov/projectile/blob/0163b335a18af0f077a474d4dc6b36e22b5e3274/projectile.el#L1335-L1340
I'm not sure if that is what you meant.
Ah, yeah - I had forgotten about this.
This issue has been automatically marked as stale because it has not had any recent activity. It will be closed soon if no further activity occurs. Thank you for your contribution and understanding!
Don't close this issue. This is an automatic message by Fresh - a bot against stale bots.
/remove-lifecycle stale
I've filed https://github.com/bbatsov/projectile/pull/1945 to implement some of this. Let's use that as a starting point, and then my subsequent idea is that there should be a buffer-local variable that is used to track whether or not the cache entry for that buffer's file is fresh - this would make it so that using M-x revert-buffer, a common way to clear settings for a buffer, would also have the side effect of allowing Projectile to re-resolve the containing project, which I feel would help match user expectations. Does that sound like a reasonable idea?
This issue has been automatically marked as stale because it has not had any recent activity. It will be closed soon if no further activity occurs. Thank you for your contribution and understanding!
We can close this for now, since the biggest issues were addressed, and discuss more specific improvements in other issues.