Subject: bug#59338: 29.0.50; Commit 1a2d603bb3 breaks Eglot on Windows

From: Danny Freeman <[email-masked]>
Date: Fri, 18 Nov 2022 09:55:47 -0500

Eli Zaretskii <[email-masked]> writes:

>> If it is a full windows path, we DO want to turn that into a file url.
>> 
>> So how do we detect that is is a windows path, and not a URL already?
>
> You test that system-type is windows-nt AND that the
> file-name-absolute-p returns non-nil for the argument.

That is incredible simple. Maybe something like this patch will work:

>From 85821844094e5d00ceb01902c55d9aa0fef73d17 Mon Sep 17 00:00:00 2001
From: dannyfreeman <[email-masked]>
Date: Fri, 18 Nov 2022 10:09:17 -0500
Subject: [PATCH] Eglot: don't confuse URLs and windows file paths

* lisp/progmodes/eglot.el (eglot--path-to-uri): check for windows path
---
 lisp/progmodes/eglot.el | 8 ++++++--
 1 file changed, 6 insertions(+), 2 deletions(-)

diff --git a/lisp/progmodes/eglot.el b/lisp/progmodes/eglot.el
index c2d7fc309d..4661cf0e1a 100644
--- a/lisp/progmodes/eglot.el
+++ b/lisp/progmodes/eglot.el
@@ -1502,11 +1502,15 @@ eglot--uri-path-allowed-chars
 (defun eglot--path-to-uri (path)
   "URIfy PATH."
   (let ((truepath (file-truename path)))
-    (if (url-type (url-generic-parse-url truepath))
+    (if (and (url-type (url-generic-parse-url path))
+             ;; It might be a windows path which includes a drive
+             ;; letter that looks like a URL scheme
+             (not (and (eq system-type 'windows-nt)
+                       (file-name-absolute-p truepath))))
         ;; Path is already a URI, so forward it to the LSP server
         ;; untouched.  The server should be able to handle it, since
         ;; it provided this URI to clients in the first place.
-        truepath
+        path
       (concat "file://"
               ;; Add a leading "/" for local MS Windows-style paths.
               (if (and (eq system-type 'windows-nt)
-- 
2.38.1

I can confirm it works on linux, but I don't have a windows machine.
Someone else would need to verify it there.

-- 
Danny Freeman