Skip to content

Commit

Permalink
Fix lsp-ui-sideline-apply-code-actions for multi-line titles
Browse files Browse the repository at this point in the history
Replace spaces and tabs just like on the sideline.
  • Loading branch information
flodiebold committed Apr 29, 2018
1 parent a5e559e commit 368cca5
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions lsp-ui-sideline.el
Original file line number Diff line number Diff line change
Expand Up @@ -322,6 +322,9 @@ CURRENT is non-nil when the point is on the symbol."
(overlay-put ov 'after-string string)
(push ov lsp-ui-sideline--ovs))))))

(defun lsp-ui-sideline--code-action-title (action)
(replace-regexp-in-string "[\n\t ]+" " " (gethash "title" action)))

(defvar-local lsp-ui-sideline--code-actions nil)

(defun lsp-ui-sideline-apply-code-actions nil
Expand All @@ -330,9 +333,9 @@ CURRENT is non-nil when the point is on the symbol."
(unless lsp-ui-sideline--code-actions
(user-error "No code actions on the current line"))
(let* ((actions lsp-ui-sideline--code-actions)
(title (completing-read "Apply: " (--map (gethash "title" it) actions)
(title (completing-read "Apply: " (-map #'lsp-ui-sideline--code-action-title actions)
nil t))
(action (--first (equal (gethash "title" it) title) actions)))
(action (--first (equal (lsp-ui-sideline--code-action-title it) title) actions)))
(unless action
(error "Fail to apply action"))
(lsp-execute-code-action action)))
Expand All @@ -341,8 +344,7 @@ CURRENT is non-nil when the point is on the symbol."
"Show code ACTIONS."
(setq lsp-ui-sideline--code-actions actions)
(dolist (action actions)
(-let* ((title (->> (gethash "title" action)
(replace-regexp-in-string "[\n\t ]+" " ")
(-let* ((title (->> (lsp-ui-sideline--code-action-title action)
(concat lsp-ui-sideline-code-actions-prefix)))
(margin (lsp-ui-sideline--margin-width))
(keymap (let ((map (make-sparse-keymap)))
Expand Down

0 comments on commit 368cca5

Please sign in to comment.