]> git.eshelyaron.com Git - emacs.git/commitdiff
Be more conservative with the lsp identifier guess
authorJoão Távora <joaotavora@gmail.com>
Fri, 15 Jul 2022 11:58:47 +0000 (12:58 +0100)
committerJoão Távora <joaotavora@gmail.com>
Fri, 15 Jul 2022 11:58:47 +0000 (12:58 +0100)
If the user is not requesting a prompt, opt for the safer approach
which is to get the location from textDocument/definition, not from
workspace/symbol.  Because of things like function overloading, the
latter is not always successful in finding exactly the definition of
the thing one is invoking M-. on.

This requires using an xref-internal symbol, which is kind of
unfortunate.

* eglot.el (xref-backend-identifier-at-point): Rework.

GitHub-reference: per https://github.com/joaotavora/eglot/issues/131
GitHub-reference: per https://github.com/joaotavora/eglot/issues/314

lisp/progmodes/eglot.el

index 22eff41f53a91ed9767f3d826d1c113142626e54..0b64cd2301bfce132ece1ffffaca83e1fb764fc1 100644 (file)
@@ -2458,10 +2458,11 @@ If BUFFER, switch to it before."
 
 (cl-defmethod xref-backend-identifier-at-point ((_backend (eql eglot)))
   (let ((attempt
-         (puthash :default
-                  (ignore-errors
-                    (eglot--workspace-symbols (symbol-name (symbol-at-point))))
-                  eglot--workspace-symbols-cache)))
+         (and (xref--prompt-p this-command)
+              (puthash :default
+                       (ignore-errors
+                         (eglot--workspace-symbols (symbol-name (symbol-at-point))))
+                       eglot--workspace-symbols-cache))))
     (if attempt (car attempt) "LSP identifier at point")))
 
 (defvar eglot--lsp-xref-refs nil