Eglot: don't watch directories that don't exist

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.
This commit is contained in:
João Távora 2023-04-02 23:01:29 +01:00
parent 82d0b6c64e
commit 86cf9fd932

View 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"