Subject: eglot crash when project-files-relative-names t
From: Ship Mints <[email-masked]>
To: [email-masked]
Date: Sun, 18 Aug 2024 11:43:01 -0400
List-Id: <debbugs-submit.debbugs.gnu.org>

project-files-relative-names was introduced a few months ago, so it's no
surprise that there are some side effects when set.

This affects the handler for workspace/didChangeWatchedFiles. The result is
that dirs-to-watch...

         (dirs-to-watch
          (delete-dups (mapcar #'file-name-directory
                               (project-files
                                (eglot--project server))))))

...is nil when project-files-relative-names is t, due to
file-name-directory failing to parse the directories it was expecting. This
results in file-readable-p failing with a nil dir:

         (watch-dir (dir)
           (when-let ((probe
                       (and (file-readable-p dir)

One solution which I've tested is simply the defensive:

         (project-files-relative-names nil) ; add this
         (dirs-to-watch
          (delete-dups (mapcar #'file-name-directory
                               (project-files
                                (eglot--project server))))))

-Stephane