summaryrefslogtreecommitdiff
path: root/lisp/progmodes
diff options
context:
space:
mode:
authorJoão Távora <joaotavora@gmail.com>2022-07-15 12:58:47 +0100
committerJoão Távora <joaotavora@gmail.com>2022-07-15 12:58:47 +0100
commit6717589c57edb96c7050df7d33cfcdc805a0eaec (patch)
tree1546289b19b127ca952d2e9fe82c4d19d80d7e27 /lisp/progmodes
parentb931d93b1549d41eb11a61724e339a4a34b317d3 (diff)
downloademacs-6717589c57edb96c7050df7d33cfcdc805a0eaec.tar.gz
emacs-6717589c57edb96c7050df7d33cfcdc805a0eaec.tar.bz2
emacs-6717589c57edb96c7050df7d33cfcdc805a0eaec.zip
Be more conservative with the lsp identifier guess
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
Diffstat (limited to 'lisp/progmodes')
-rw-r--r--lisp/progmodes/eglot.el9
1 files changed, 5 insertions, 4 deletions
diff --git a/lisp/progmodes/eglot.el b/lisp/progmodes/eglot.el
index 22eff41f53a..0b64cd2301b 100644
--- a/lisp/progmodes/eglot.el
+++ b/lisp/progmodes/eglot.el
@@ -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