From 368cca5f26fc4908c6a469d8a8226e0bd47f078e Mon Sep 17 00:00:00 2001 From: Florian Diebold Date: Sun, 29 Apr 2018 17:24:32 +0200 Subject: [PATCH] Fix lsp-ui-sideline-apply-code-actions for multi-line titles Replace spaces and tabs just like on the sideline. --- lsp-ui-sideline.el | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/lsp-ui-sideline.el b/lsp-ui-sideline.el index f4623fc4..e3eaf83d 100644 --- a/lsp-ui-sideline.el +++ b/lsp-ui-sideline.el @@ -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 @@ -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))) @@ -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)))