[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
master b5de9ae8010: Eglot: careful when invoking code actions on no symb
From: |
João Távora |
Subject: |
master b5de9ae8010: Eglot: careful when invoking code actions on no symbol at all |
Date: |
Sat, 6 Jan 2024 19:13:48 -0500 (EST) |
branch: master
commit b5de9ae8010684a5ed0c6f2703077a61d325ccad
Author: João Távora <joaotavora@gmail.com>
Commit: João Távora <joaotavora@gmail.com>
Eglot: careful when invoking code actions on no symbol at all
Invoking code actions without a marked region or over a symbol
will trip certain servers up since BEG and END in eglot-code-actions
will be nil, causing 'eglot--pos-to-lsp-position' to assume point (which
is OK) but the 'flymake-diagnostics' call to return all diagnostics.
This causes an absolutely undecipherable JavaScript backtrace to be
sent back to Eglot from typescript-language-server.
Github-reference: https://github.com/joaotavora/eglot/issues/847
* lisp/progmodes/eglot.el (eglot--code-action-bounds): Avoid returning
(list nil nil)
---
lisp/progmodes/eglot.el | 7 ++++---
1 file changed, 4 insertions(+), 3 deletions(-)
diff --git a/lisp/progmodes/eglot.el b/lisp/progmodes/eglot.el
index d330e6e23cb..ba2cc72a6b4 100644
--- a/lisp/progmodes/eglot.el
+++ b/lisp/progmodes/eglot.el
@@ -3605,16 +3605,17 @@ edit proposed by the server."
(defun eglot--code-action-bounds ()
"Calculate appropriate bounds depending on region and point."
- (let (diags)
+ (let (diags boftap)
(cond ((use-region-p) `(,(region-beginning) ,(region-end)))
((setq diags (flymake-diagnostics (point)))
(cl-loop for d in diags
minimizing (flymake-diagnostic-beg d) into beg
maximizing (flymake-diagnostic-end d) into end
finally (cl-return (list beg end))))
+ ((setq boftap (bounds-of-thing-at-point 'sexp))
+ (list (car boftap) (cdr boftap)))
(t
- (let ((boftap (bounds-of-thing-at-point 'sexp)))
- (list (car boftap) (cdr boftap)))))))
+ (list (point) (point))))))
(defun eglot-code-actions (beg &optional end action-kind interactive)
"Find LSP code actions of type ACTION-KIND between BEG and END.
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- master b5de9ae8010: Eglot: careful when invoking code actions on no symbol at all,
João Távora <=