From 86cf9fd932c654cc502bedf634458a918ee5e9cb Mon Sep 17 00:00:00 2001 From: =?utf8?q?Jo=C3=A3o=20T=C3=A1vora?= Date: Sun, 2 Apr 2023 23:01:29 +0100 Subject: [PATCH] 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. --- lisp/progmodes/eglot.el | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/lisp/progmodes/eglot.el b/lisp/progmodes/eglot.el index 8f64f849d72..4a9209ab9b4 100644 --- a/lisp/progmodes/eglot.el +++ b/lisp/progmodes/eglot.el @@ -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" -- 2.39.2