branch: externals/elpa
commit b34447c6698837186552e4bab6b1a422b45e42dd
Author: muffinmad <[email protected]>
Commit: João Távora <[email protected]>
Close #473: simplify eglot-code-actions
If no region is active, ask for code actions at point, even if there
are no diagnostics at point.
Co-authored-by: João Távora <[email protected]>
* eglot.el (eglot-code-actions): Simplify.
---
eglot.el | 14 ++++++--------
1 file changed, 6 insertions(+), 8 deletions(-)
diff --git a/eglot.el b/eglot.el
index 8bb610b..4b25368 100644
--- a/eglot.el
+++ b/eglot.el
@@ -2563,15 +2563,13 @@ documentation. Honour `eglot-put-doc-in-help-buffer',
current-prefix-arg))
-(defun eglot-code-actions (&optional beg end)
- "Get and offer to execute code actions between BEG and END."
+(defun eglot-code-actions (beg &optional end)
+ "Offer to execute code actions between BEG and END.
+Interactively, if a region is active, BEG and END are its bounds,
+else BEG is point and END is nil, which results in a request for
+code actions at point"
(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) `(,(region-beginning) ,(region-end)) `(,(point) nil)))
(unless (eglot--server-capable :codeActionProvider)
(eglot--error "Server can't execute code actions!"))
(let* ((server (eglot--current-server-or-lose))