diff options
| author | Bozhidar Batsov <bozhidar@batsov.dev> | 2026-03-04 21:34:41 +0200 |
|---|---|---|
| committer | Bozhidar Batsov <bozhidar@batsov.dev> | 2026-03-04 21:43:10 +0200 |
| commit | 490067591660e0901358656152066a5c5221ff5c (patch) | |
| tree | 50ad2a2018d4b349450b7e4fc83582b820bf8118 | |
| parent | d29b5b3526b4ee0335e92f93997cb4ac12f14fef (diff) | |
Wrap add-dir-local-variable in save-selected-window in toggle-read-only
add-dir-local-variable switches to the .dir-locals.el buffer.
Without save-selected-window, kill-buffer and the subsequent
buffer-file-name check operated on unpredictable buffers. This
matches the pattern already used in projectile-add-dir-local-variable.
| -rw-r--r-- | projectile.el | 7 |
1 files changed, 4 insertions, 3 deletions
diff --git a/projectile.el b/projectile.el index 65b38ee..7c2b0f7 100644 --- a/projectile.el +++ b/projectile.el @@ -2671,9 +2671,10 @@ With a prefix arg INVALIDATE-CACHE invalidates the cache first." (let ((inhibit-read-only t) (val (not buffer-read-only)) (default-directory (projectile-acquire-root))) - (add-dir-local-variable nil 'buffer-read-only val) - (save-buffer) - (kill-buffer) + (save-selected-window + (add-dir-local-variable nil 'buffer-read-only val) + (save-buffer) + (kill-buffer)) (when buffer-file-name (read-only-mode (if val +1 -1)) (message "[%s] read-only-mode is %s" (projectile-project-name) (if val "on" "off"))))) |
