@@ -6111,12 +6111,28 @@ It will show up only if current point has signature help."
6111
6111
6112
6112
(defun lsp--text-document-code-action-params (&optional kind)
6113
6113
"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* ((diags (lsp-cur-possition-diagnostics))
6115
+ (range (cond ((use-region-p)
6116
+ (lsp--region-to-range (region-beginning) (region-end)))
6117
+ (diags
6118
+ (let* ((start (point))
6119
+ (end (point)))
6120
+ (seq-doseq (diag diags)
6121
+ (when-let* ((diag-range (gethash "range" diag))
6122
+ (diag-start (gethash "start" diag-range))
6123
+ (l1 (gethash "line" diag-start))
6124
+ (c1 (gethash "character" diag-start))
6125
+ (diag-end (gethash "end" diag-range))
6126
+ (l2 (gethash "line" diag-end))
6127
+ (c2 (gethash "character" diag-end)))
6128
+ (setq start (min (lsp--line-character-to-point l1 c1) start))
6129
+ (setq end (max (lsp--line-character-to-point l2 c2) end))))
6130
+ (lsp--region-to-range start end)))
6131
+ (t (lsp--region-to-range (point) (point))))))
6132
+ (list :textDocument (lsp--text-document-identifier)
6133
+ :range range
6134
+ :context `( :diagnostics ,diags
6135
+ ,@(when kind (list :only (vector kind)))))))
6120
6136
6121
6137
(defun lsp-code-actions-at-point (&optional kind)
6122
6138
"Retrieve the code actions for the active region or the current line.
0 commit comments