From 924d73120bca6adc5b9bf3d79ad53075a63b5f1e Mon Sep 17 00:00:00 2001 From: Ivan Malison Date: Sat, 21 Mar 2015 19:17:01 -0700 Subject: [PATCH] [Fix #667] Use file-truename when caching current file --- CHANGELOG.md | 1 + projectile.el | 8 ++++---- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 0a2a79af8..b3d4018e7 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -16,6 +16,7 @@ ### Bugs fixed * [#721](https://github.com/bbatsov/projectile/issues/721#issuecomment-100830507): Remove current buffer from `helm-projectile-switch-project`. +* [#667](https://github.com/bbatsov/projectile/issues/667) Use `file-truename` when caching filenames to prevent duplicate/symlinked filepaths from appearing when opening a project file. ## 0.12.0 (03/29/2015) diff --git a/projectile.el b/projectile.el index 4ebd4a4e2..2a8aaf79d 100644 --- a/projectile.el +++ b/projectile.el @@ -553,10 +553,10 @@ The cache is created both in memory and on the hard drive." (defun projectile-cache-current-file () "Add the currently visited file to the cache." (interactive) - (let* ((current-project (projectile-project-root)) - (abs-current-file (buffer-file-name (current-buffer))) - (current-file (file-relative-name abs-current-file current-project))) + (let ((current-project (projectile-project-root))) (when (gethash (projectile-project-root) projectile-projects-cache) + (let* ((abs-current-file (file-truename (buffer-file-name (current-buffer)))) + (current-file (file-relative-name abs-current-file current-project))) (unless (or (projectile-file-cached-p current-file current-project) (projectile-ignored-directory-p (file-name-directory abs-current-file)) (projectile-ignored-file-p abs-current-file)) @@ -566,7 +566,7 @@ The cache is created both in memory and on the hard drive." (projectile-serialize-cache) (message "File %s added to project %s cache." (propertize current-file 'face 'font-lock-keyword-face) - (propertize current-project 'face 'font-lock-keyword-face)))))) + (propertize current-project 'face 'font-lock-keyword-face))))))) ;; cache opened files automatically to reduce the need for cache invalidation (defun projectile-cache-files-find-file-hook ()