]> git.eshelyaron.com Git - emacs.git/commitdiff
Don't choke on workspace/configuration with no scopeuri
authorJoão Távora <joaotavora@gmail.com>
Tue, 5 Nov 2019 23:53:35 +0000 (23:53 +0000)
committerJoão Távora <joaotavora@gmail.com>
Sat, 9 Nov 2019 22:07:49 +0000 (22:07 +0000)
* eglot.el (eglot-handle-request): Don't choke on nil scopeUri.

GitHub-reference: fix https://github.com/joaotavora/eglot/issues/340

lisp/progmodes/eglot.el

index a0f57f416020991a2f3525731becd5c5d14618c5..7133426021bc1e5264e27841d2ed8f866ea3ba52 100644 (file)
@@ -1678,20 +1678,23 @@ When called interactively, use the currently active server"
   (apply #'vector
          (mapcar
           (eglot--lambda ((ConfigurationItem) scopeUri section)
-            (let* ((path (eglot--uri-to-path scopeUri)))
-              (when (file-directory-p path)
-                (with-temp-buffer
-                  (let ((default-directory path))
-                    (setq-local major-mode (eglot--major-mode server))
-                    (hack-dir-local-variables-non-file-buffer)
-                    (alist-get section eglot-workspace-configuration
-                               nil nil
-                               (lambda (wsection section)
-                                 (string=
-                                  (if (keywordp wsection)
-                                      (substring (symbol-name wsection) 1)
-                                    wsection)
-                                  section))))))))
+            (with-temp-buffer
+              (let* ((uri-path (eglot--uri-to-path scopeUri))
+                     (default-directory
+                       (if (and (not (string-empty-p uri-path))
+                                (file-directory-p uri-path))
+                           uri-path
+                           (car (project-roots (eglot--project server))))))
+                (setq-local major-mode (eglot--major-mode server))
+                (hack-dir-local-variables-non-file-buffer)
+                (alist-get section eglot-workspace-configuration
+                           nil nil
+                           (lambda (wsection section)
+                             (string=
+                              (if (keywordp wsection)
+                                  (substring (symbol-name wsection) 1)
+                                wsection)
+                              section))))))
           items)))
 
 (defun eglot--signal-textDocument/didChange ()