From 9135298c45f2f03ab92903edb242c8f5f94396d5 Mon Sep 17 00:00:00 2001 From: Craig Jennings Date: Sun, 24 May 2026 07:22:56 -0500 Subject: fix(modeline): key VC cache on resolved truename for symlink moves The VC modeline cache keyed on (list file cj/modeline-vc-show-remote). If file was a symlink whose target moved to a different VC tree (shared drives, CI workspaces), the key was unchanged and the cache kept serving the old branch/state. Added the resolved file-truename to the key, so a symlink re-pointed at a new target produces a different key and the cache refreshes. The extra file-truename is one stat per modeline refresh, cheap next to the VC calls the cache exists to avoid. Tests cover truename inclusion, key stability for an unchanged file, and a symlink whose target moves. --- modules/modeline-config.el | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) (limited to 'modules') diff --git a/modules/modeline-config.el b/modules/modeline-config.el index 61ab0f9d..5afe226e 100644 --- a/modules/modeline-config.el +++ b/modules/modeline-config.el @@ -129,8 +129,12 @@ Uses built-in cached values for performance.") cj/modeline-vc-cache-set-p nil)) (defun cj/modeline-vc-cache-key (file) - "Return the cache key for FILE." - (list file cj/modeline-vc-show-remote)) + "Return the cache key for FILE. +Includes the resolved `file-truename' so that if FILE is a symlink whose +target moves to a different VC tree, the key changes and the cache is not +served a stale backend. The extra `file-truename' is one stat per refresh, +cheap next to the VC calls the cache avoids." + (list file (file-truename file) cj/modeline-vc-show-remote)) (defun cj/modeline-vc-cache-valid-p (key now) "Return non-nil when cached VC data is valid for KEY at NOW." -- cgit v1.2.3