Skip to content

Commit

Permalink
Send point or region as code acrion range
Browse files Browse the repository at this point in the history
* eglot.el (eglot-code-actions): Send region as codeAction range
if region is active. Otherwise send just point.
  • Loading branch information
muffinmad committed May 13, 2020
1 parent da7ff48 commit 547ea03
Showing 1 changed file with 3 additions and 6 deletions.
9 changes: 3 additions & 6 deletions eglot.el
Original file line number Diff line number Diff line change
Expand Up @@ -2534,12 +2534,9 @@ documentation. Honour `eglot-put-doc-in-help-buffer',
(defun eglot-code-actions (&optional beg end)
"Get and offer to execute code actions between BEG and END."
(interactive
(let (diags)
(cond ((region-active-p) (list (region-beginning) (region-end)))
((setq diags (flymake-diagnostics (point)))
(list (cl-reduce #'min (mapcar #'flymake-diagnostic-beg diags))
(cl-reduce #'max (mapcar #'flymake-diagnostic-end diags))))
(t (list (point-min) (point-max))))))
(if (region-active-p)
(list (region-beginning) (region-end))
(list (point) (point))))
(unless (eglot--server-capable :codeActionProvider)
(eglot--error "Server can't execute code actions!"))
(let* ((server (eglot--current-server-or-lose))
Expand Down

0 comments on commit 547ea03

Please sign in to comment.