GNU bug report logs - #78392
31.0.50; eglot breaks on xref-find-definitions

Previous Next

Package: emacs;

Reported by: "admin <at> sonictk.com" <admin <at> sonictk.com>

Date: Mon, 12 May 2025 14:48:02 UTC

Severity: normal

Found in version 31.0.50

Done: Eli Zaretskii <eliz <at> gnu.org>

Bug is archived. No further changes may be made.

Full log


Message #17 received at 78392 <at> debbugs.gnu.org (full text, mbox):

From: João Távora <joaotavora <at> gmail.com>
To: admin <at> sonictk.com
Cc: Eli Zaretskii <eliz <at> gnu.org>, 78392 <at> debbugs.gnu.org
Subject: Re: bug#78392: 31.0.50; eglot breaks on xref-find-definitions
Date: Mon, 12 May 2025 21:10:21 +0100
[Message part 1 (text/plain, inline)]
Thanks. I think the patch makes sense. Free to push. If you can, please
prefix the first line of commit message with "Eglot: ", like the other ones
to this file.

João

On Mon, May 12, 2025, 20:57 admin <at> sonictk.com <admin <at> sonictk.com> wrote:

> Hi Eli:
>
> Thanks for responding. Confirmed that applying the patch locally solves
> the issue. Appreciate the help here!
>
>
> ------------------------------
> *From:* Eli Zaretskii <eliz <at> gnu.org>
> *Sent:* Monday, May 12, 2025 8:16 AM
> *To:* admin <at> sonictk.com <admin <at> sonictk.com>; João Távora <
> joaotavora <at> gmail.com>
> *Cc:* 78392 <at> debbugs.gnu.org <78392 <at> debbugs.gnu.org>
> *Subject:* Re: bug#78392: 31.0.50; eglot breaks on xref-find-definitions
>
> > From: "admin <at> sonictk.com" <admin <at> sonictk.com>
> > Date: Mon, 12 May 2025 06:29:15 +0000
> >
> > Currently, when building from latest Emacs ToT, activating `eglot-mode`
> > in any C++ file using `clangd` and attempting to call
> > `xref-find-definitions` on any definition results in the following error
> > being triggered:
> >
> > ```
> > Opening input file: Is a directory, c:/Users/sonictk/tmp
> > ```
> >
> > Where the `.cpp` file is in the given directory. Tried building Emacs
> > using a build from a month-ish ago to find where the regression first
> > occurred and it still had the issue present, even when doing `make
> > distclean` and then `make bootstrap` after re-running `./configure`.
> >
> > `toggle-debug-on-error` gives me:
> >
> > ```
> > Debugger entered--Lisp error: (file-error "Opening input file" "Is a
> directory" "c:/Users/sonictk/tmp")
> >   eglot--xref-make-match(#("Baz" 0 3 (face font-lock-function-name-face
> fontified t))
> > "file:///c:/Users/sonictk/tmp/test2.cpp" (:end (:character 11 :line 23)
> :start (:character 8 :line 23)))
> >   #f(compiled-function (loc-or-loc-link) #<bytecode
> 0x413eb090fd3d661>)((:range (:end (:character 11 :line
> > 23) :start (:character 8 :line 23)) :uri "
> file:///c:/Users/sonictk/tmp/test2.cpp"))
> >   eglot--lsp-xrefs-for-method(:textDocument/definition)
> >   #f(compiled-function (backend id) #<bytecode
> -0x10624bec505aa107>)(eglot "LSP identifier at point")
> >   apply(#f(compiled-function (backend id) #<bytecode
> -0x10624bec505aa107>) eglot "LSP identifier at
> > point")
> >   xref-backend-definitions(eglot "LSP identifier at point")
> >   #f(compiled-function () #<bytecode 0x558a9dc3551d156>)()
> >   xref-show-definitions-buffer(#f(compiled-function () #<bytecode
> 0x558a9dc3551d156>) ((window .
> > #<window 9 on test2.cpp>) (display-action) (auto-jump)))
> >   xref--show-defs(#f(compiled-function () #<bytecode 0x558a9dc3551d156>)
> nil)
> >   xref--find-definitions("LSP identifier at point" nil)
> >   xref-find-definitions("LSP identifier at point")
> >   funcall-interactively(xref-find-definitions "LSP identifier at point")
> >   command-execute(xref-find-definitions)
> > ```
>
> Thanks.  Does the patch below give good results?
>
> João, I think the assumption that 'retval' there necessarily starts
> with a slash is because url-generic-parse-url would not necessarily
> DTRT with Windows file:// URIs; it was fixed lately.  So now we need
> to test for that before applying the fixup.
>
> diff --git a/lisp/progmodes/eglot.el b/lisp/progmodes/eglot.el
> index eae8e1b..6f6b05a 100644
> --- a/lisp/progmodes/eglot.el
> +++ b/lisp/progmodes/eglot.el
> @@ -1165,7 +1165,8 @@ eglot-uri-to-path
>                 ;; Remove the leading "/" for local MS Windows-style paths.
>                 (normalized (if (and (not remote-prefix)
>                                      (eq system-type 'windows-nt)
> -                                    (cl-plusp (length retval)))
> +                                    (cl-plusp (length retval))
> +                                    (eq (aref retval 0) ?/))
>                                 (w32-long-file-name (substring retval 1))
>                               retval)))
>            (concat remote-prefix normalized))
>
>
[Message part 2 (text/html, inline)]

This bug report was last modified 8 days ago.

Previous Next


GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997,2003 nCipher Corporation Ltd, 1994-97 Ian Jackson.