From 8b4e81cdcf57a1eca09523c84bb3389d3549131d Mon Sep 17 00:00:00 2001 From: =?utf8?q?Jo=C3=A3o=20T=C3=A1vora?= Date: Tue, 5 Nov 2019 23:53:35 +0000 Subject: [PATCH] Don't choke on workspace/configuration with no scopeuri * 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 | 31 +++++++++++++++++-------------- 1 file changed, 17 insertions(+), 14 deletions(-) diff --git a/lisp/progmodes/eglot.el b/lisp/progmodes/eglot.el index a0f57f41602..7133426021b 100644 --- a/lisp/progmodes/eglot.el +++ b/lisp/progmodes/eglot.el @@ -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 () -- 2.39.2