Skip to content

Commit 7ab2f86

Browse files
committed
`lsp--code-action-title': preferred + disabled
`lsp--code-action-title': handle both preferred and disabled code actions, because the LSP protocol does not forbid that case. Such a code action might be a refactoring that addresses the issue but can't be executed because there isn't enough RAM, for example.
1 parent 57be94d commit 7ab2f86

File tree

1 file changed

+8
-11
lines changed

1 file changed

+8
-11
lines changed

lsp-mode.el

Lines changed: 8 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -4892,17 +4892,14 @@ Shown after the code action in `lsp-execute-code-action',
48924892

48934893
(lsp-defun lsp--code-action-title ((action &as &CodeAction :title :is-preferred? :disabled?))
48944894
"Render an `&CodeAction' as a propertized string."
4895-
;; It would be strange for a code action to be both preferred and disabled, so
4896-
;; `cond' is probably good enough.
4897-
(cond (is-preferred?
4898-
(propertize title 'face 'lsp-preferred-code-action-face))
4899-
(disabled?
4900-
(concat
4901-
(propertize title 'face 'lsp-disabled-code-action-face)
4902-
;; Support spec-breaking servers that don't specify a reason.
4903-
(when-let ((reason (lsp:code-action-disabled-reason disabled?)))
4904-
(concat " " (propertize reason 'face 'lsp-disabled-code-action-reason-face)))))
4905-
(t title)))
4895+
(--doto (copy-sequence title)
4896+
(let ((len (length it)))
4897+
(when is-preferred?
4898+
(add-face-text-property 0 len 'lsp-preferred-code-action-face nil it))
4899+
(when disabled?
4900+
(add-face-text-property 0 len 'lsp-disabled-code-action-face nil it)
4901+
(-when-let ((&CodeActionDisabled :reason) disabled?)
4902+
(cl-callf concat it " " (propertize reason 'face 'lsp-disabled-code-action-reason-face)))))))
49064903

49074904
(defun lsp--select-action (actions)
49084905
"Select an action to execute from ACTIONS."

0 commit comments

Comments
 (0)