[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[elpa] externals/elpa e5cf30e 09/71: Close #435: create match xrefs when
From: |
João Távora |
Subject: |
[elpa] externals/elpa e5cf30e 09/71: Close #435: create match xrefs when possible |
Date: |
Wed, 16 Dec 2020 11:42:14 -0500 (EST) |
branch: externals/elpa
commit e5cf30e26bd3107583418f2b4539c7385d37d6c8
Author: Trevor Murphy <trevormurphy@google.com>
Commit: GitHub <noreply@github.com>
Close #435: create match xrefs when possible
"Match xrefs" are created with `xref-make-match' instead of
`xref-make'. Match xrefs support `xref-query-replace-in-results' from
the results buffer.
* eglot.el (eglot--xref-make-match): Calculate xref match length from
the eglot range.
---
eglot.el | 22 +++++++++++++---------
1 file changed, 13 insertions(+), 9 deletions(-)
diff --git a/eglot.el b/eglot.el
index 3ea8391..c7c4551 100644
--- a/eglot.el
+++ b/eglot.el
@@ -1833,8 +1833,8 @@ Calls REPORT-FN maybe if server publishes diagnostics in
time."
(maphash (lambda (_uri buf) (kill-buffer buf))
eglot--temp-location-buffers)
(clrhash eglot--temp-location-buffers))))
-(defun eglot--xref-make (name uri range)
- "Like `xref-make' but with LSP's NAME, URI and RANGE.
+(defun eglot--xref-make-match (name uri range)
+ "Like `xref-make-match' but with LSP's NAME, URI and RANGE.
Try to visit the target file for a richer summary line."
(pcase-let*
((file (eglot--uri-to-path uri))
@@ -1849,8 +1849,9 @@ Try to visit the target file for a richer summary line."
(hi-end (- (min (point-at-eol) end) bol)))
(add-face-text-property hi-beg hi-end 'highlight
t substring)
- (list substring (1+ (current-line))
(eglot-current-column))))))
- (`(,summary ,line ,column)
+ (list substring (1+ (current-line)) (eglot-current-column)
+ (- end beg))))))
+ (`(,summary ,line ,column ,length)
(cond
(visiting (with-current-buffer visiting (funcall collect)))
((file-readable-p file) (with-current-buffer
@@ -1859,9 +1860,12 @@ Try to visit the target file for a richer summary line."
(insert-file-contents file)
(funcall collect)))
(t ;; fall back to the "dumb strategy"
- (let ((start (cl-getf range :start)))
- (list name (1+ (cl-getf start :line)) (cl-getf start
:character)))))))
- (xref-make summary (xref-make-file-location file line column))))
+ (let* ((start (cl-getf range :start))
+ (line (1+ (cl-getf start :line)))
+ (start-pos (cl-getf start :character))
+ (end-pos (cl-getf (cl-getf range :end) :character)))
+ (list name line start-pos (- end-pos start-pos)))))))
+ (xref-make-match summary (xref-make-file-location file line column)
length)))
(cl-defmethod xref-backend-identifier-completion-table ((_backend (eql eglot)))
(eglot--error "cannot (yet) provide reliable completion table for LSP
symbols"))
@@ -1892,7 +1896,7 @@ Try to visit the target file for a richer summary line."
(eglot--collecting-xrefs (collect)
(mapc
(eglot--lambda ((Location) uri range)
- (collect (eglot--xref-make (symbol-at-point) uri range)))
+ (collect (eglot--xref-make-match (symbol-at-point) uri range)))
(if (vectorp response) response (list response))))))
(cl-defun eglot--lsp-xref-helper (method &key extra-params capability )
@@ -1935,7 +1939,7 @@ Try to visit the target file for a richer summary line."
(mapc
(eglot--lambda ((SymbolInformation) name location)
(eglot--dbind ((Location) uri range) location
- (collect (eglot--xref-make name uri range))))
+ (collect (eglot--xref-make-match name uri range))))
(jsonrpc-request (eglot--current-server-or-lose)
:workspace/symbol
`(:query ,pattern))))))
- [elpa] branch externals/elpa created (now 4edd478), João Távora, 2020/12/16
- [elpa] externals/elpa 8b94cf4 02/71: Per #397: Add new eglot-lsp-abiding-column test, João Távora, 2020/12/16
- [elpa] externals/elpa 1056ef5 03/71: Close #413: update dependencies and copyright years, João Távora, 2020/12/16
- [elpa] externals/elpa d99a447 12/71: Close #439: Hide eldoc-message on empty hover info, João Távora, 2020/12/16
- [elpa] externals/elpa af32ebf 06/71: Close #444: use text-mode for plaintext markup, João Távora, 2020/12/16
- [elpa] externals/elpa ef6c483 13/71: Fix #452: also check types when destructuring LSP objects, João Távora, 2020/12/16
- [elpa] externals/elpa 487cde5 18/71: Close #443: kind of honour eldoc-echo-area-use-multiline-p, João Távora, 2020/12/16
- [elpa] externals/elpa 22aa27c 01/71: Close #397: Simplify a bit of code, João Távora, 2020/12/16
- [elpa] externals/elpa 8900a35 04/71: Prevent "Cant guess python-indent-offset..." messages in tests, João Távora, 2020/12/16
- [elpa] externals/elpa dd48f4a 08/71: * eglot.el (eglot-put-doc-in-help-buffer): Tiny docstring fix., João Távora, 2020/12/16
- [elpa] externals/elpa e5cf30e 09/71: Close #435: create match xrefs when possible,
João Távora <=
- [elpa] externals/elpa ad3f049 24/71: Close #417: minimally document relation with project.el, João Távora, 2020/12/16
- [elpa] externals/elpa 2f75da2 28/71: Fix #460: fix "free variable" warning, João Távora, 2020/12/16
- [elpa] externals/elpa 0f57efb 26/71: Simplify bug-reporting instructions, João Távora, 2020/12/16
- [elpa] externals/elpa 91a7cba 33/71: Fix #474, #478: prompt for executable if supplied name does not exist, João Távora, 2020/12/16
- [elpa] externals/elpa 9efe207 05/71: Make curl invocation fail more explicitly in .travis.yml, João Távora, 2020/12/16
- [elpa] externals/elpa 73bc752 11/71: Close #441: shield tests from some user customizations, João Távora, 2020/12/16
- [elpa] externals/elpa b6519a5 16/71: Per #446: Add tests for eglot-server-programs, João Távora, 2020/12/16
- [elpa] externals/elpa 9bc58df 17/71: Fix #446: unbreak eglot--guess-contact for host-and-port case, João Távora, 2020/12/16
- [elpa] externals/elpa 197984c 27/71: Remove trailing whitespaces, João Távora, 2020/12/16
- [elpa] externals/elpa a0249c8 23/71: Per #437: remap display-local-help (C-h .) to eglot-help-at-point, João Távora, 2020/12/16