Skip to content

Commit f752629

Browse files
authored
lsp-code-actions: getting location of diagnostics wrt LSP_USE_PLISTS (#4849)
1 parent 65a414d commit f752629

File tree

1 file changed

+18
-6
lines changed

1 file changed

+18
-6
lines changed

lsp-mode.el

Lines changed: 18 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -6111,12 +6111,24 @@ It will show up only if current point has signature help."
61116111

61126112
(defun lsp--text-document-code-action-params (&optional kind)
61136113
"Code action params."
6114-
(list :textDocument (lsp--text-document-identifier)
6115-
:range (if (use-region-p)
6116-
(lsp--region-to-range (region-beginning) (region-end))
6117-
(lsp--region-to-range (point) (point)))
6118-
:context `( :diagnostics ,(lsp-cur-possition-diagnostics)
6119-
,@(when kind (list :only (vector kind))))))
6114+
(let* ((diagnostics (lsp-cur-possition-diagnostics))
6115+
(range (cond ((use-region-p)
6116+
(lsp--region-to-range (region-beginning) (region-end)))
6117+
(diagnostics
6118+
(let* ((start (point)) (end (point)))
6119+
(mapc (-lambda
6120+
((&Diagnostic
6121+
:range (&Range :start (&Position :line l1 :character c1)
6122+
:end (&Position :line l2 :character c2))))
6123+
(setq start (min (lsp--line-character-to-point l1 c1) start))
6124+
(setq end (max (lsp--line-character-to-point l2 c2) end)))
6125+
diagnostics)
6126+
(lsp--region-to-range start end)))
6127+
(t (lsp--region-to-range (point) (point))))))
6128+
(list :textDocument (lsp--text-document-identifier)
6129+
:range range
6130+
:context `( :diagnostics ,diagnostics
6131+
,@(when kind (list :only (vector kind)))))))
61206132

61216133
(defun lsp-code-actions-at-point (&optional kind)
61226134
"Retrieve the code actions for the active region or the current line.

0 commit comments

Comments
 (0)