diff options
| author | Bozhidar Batsov <bozhidar@batsov.dev> | 2025-02-03 20:52:47 +0200 |
|---|---|---|
| committer | Bozhidar Batsov <bozhidar@batsov.dev> | 2025-02-03 20:52:47 +0200 |
| commit | 0efac68c82d8ebdb3fd83ea5e530c4b816c87f8f (patch) | |
| tree | 452d94d601b550ec971f006e6c9c94eee4f4876d /projectile.el | |
| parent | e6c0f5f236b2e60fcf7f8d090fb3e2af0096d4ff (diff) | |
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.
Diffstat (limited to 'projectile.el')
| -rw-r--r-- | projectile.el | 10 |
1 files changed, 8 insertions, 2 deletions
diff --git a/projectile.el b/projectile.el index 1962fb0..1f8f6c2 100644 --- a/projectile.el +++ b/projectile.el @@ -1166,9 +1166,15 @@ The cache is created both in memory and on the hard drive." (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)) - (let ((project-files (cons current-file (gethash current-project projectile-projects-cache)))) + (let ((project-files (cons current-file (gethash current-project projectile-projects-cache))) + (cache-file (projectile-project-cache-file current-project))) (puthash current-project project-files projectile-projects-cache) - (projectile-serialize project-files (projectile-project-cache-file current-project))) + ;; we serialize the cache with an idle time to avoid freezing the UI + ;; immediately after the new file was created + (run-with-idle-timer + 30 + nil + 'projectile-serialize project-files cache-file)) (message "File %s added to project %s cache." (propertize current-file 'face 'font-lock-keyword-face) (propertize current-project 'face 'font-lock-keyword-face))))))) |
