Skip to content

Commit 0efac68

Browse files
committed
Use an idle timer in projectile-cache-current-file
This prevents freezes when creating new files, as the function is triggered by find-file-hook.
1 parent e6c0f5f commit 0efac68

File tree

1 file changed

+8
-2
lines changed

1 file changed

+8
-2
lines changed

projectile.el

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1166,9 +1166,15 @@ The cache is created both in memory and on the hard drive."
11661166
(unless (or (projectile-file-cached-p current-file current-project)
11671167
(projectile-ignored-directory-p (file-name-directory abs-current-file))
11681168
(projectile-ignored-file-p abs-current-file))
1169-
(let ((project-files (cons current-file (gethash current-project projectile-projects-cache))))
1169+
(let ((project-files (cons current-file (gethash current-project projectile-projects-cache)))
1170+
(cache-file (projectile-project-cache-file current-project)))
11701171
(puthash current-project project-files projectile-projects-cache)
1171-
(projectile-serialize project-files (projectile-project-cache-file current-project)))
1172+
;; we serialize the cache with an idle time to avoid freezing the UI
1173+
;; immediately after the new file was created
1174+
(run-with-idle-timer
1175+
30
1176+
nil
1177+
'projectile-serialize project-files cache-file))
11721178
(message "File %s added to project %s cache."
11731179
(propertize current-file 'face 'font-lock-keyword-face)
11741180
(propertize current-project 'face 'font-lock-keyword-face)))))))

0 commit comments

Comments
 (0)