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)
This commit is contained in:
parent
73cb931e5b
commit
b5de9ae801
1 changed files with 4 additions and 3 deletions
|
@ -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.
|
||||
|
|
Loading…
Add table
Reference in a new issue