]> git.eshelyaron.com Git - emacs.git/commitdiff
Eglot: don't watch directories that don't exist
authorJoão Távora <joaotavora@gmail.com>
Sun, 2 Apr 2023 22:01:29 +0000 (23:01 +0100)
committerJoão Távora <joaotavora@gmail.com>
Sun, 2 Apr 2023 22:02:38 +0000 (23:02 +0100)
project-files isn't guaranteed to return existing files, so better
check if they exist because placing a watcher on them.

Originally reported at:
https://github.com/joaotavora/eglot/issues/1198

* lisp/progmodes/eglot.el (eglot-register-capability
workspace/didChangeWatchedFiles): Check if directories exist.

lisp/progmodes/eglot.el

index 8f64f849d72f8ec86cc5ac036ea7b4df2966a745..4a9209ab9b43c6d2eb68167f5658b7856e9227d7 100644 (file)
@@ -3433,8 +3433,9 @@ at point.  With prefix argument, prompt for ACTION-KIND."
       (unwind-protect
           (progn
             (dolist (dir dirs-to-watch)
-              (push (file-notify-add-watch dir '(change) #'handle-event)
-                    (gethash id (eglot--file-watches server))))
+              (when (file-readable-p dir)
+                (push (file-notify-add-watch dir '(change) #'handle-event)
+                      (gethash id (eglot--file-watches server)))))
             (setq
              success
              `(:message ,(format "OK, watching %s directories in %s watchers"