Consider a single newline terminated string as single line

* eldoc-box.el (eldoc-box--eldoc-message-function): Trim newlines in
DOC. Rename 'multi-line-p' to 'single-line-p'.
This commit is contained in:
Jimmy Yuen Ho Wong 2021-03-26 09:00:53 +00:00 committed by Yuan Fu
parent d4574ee392
commit eb694dde6b
No known key found for this signature in database
GPG Key ID: 56E19BC57664A442

View File

@ -405,10 +405,10 @@ Checkout `lsp-ui-doc--make-frame', `lsp-ui-doc--move-frame'."
(defun eldoc-box--eldoc-message-function (str &rest args)
"Front-end for eldoc. Display STR in childframe and ARGS works like `message'."
(when (and (stringp str) (not (equal str "")))
(let* ((doc (apply #'format str args))
(multi-line-p (and eldoc-box-only-multi-line
(let* ((doc (string-trim-right (apply #'format str args)))
(single-line-p (and eldoc-box-only-multi-line
(eq (cl-count ?\n doc) 0))))
(unless multi-line-p
(unless single-line-p
(eldoc-box--display doc)
(setq eldoc-box--last-point (point))
;; Why a timer? ElDoc is mainly used in minibuffer,
@ -420,7 +420,7 @@ Checkout `lsp-ui-doc--make-frame', `lsp-ui-doc--move-frame'."
;; command if `eldoc-box-hover-mode' is on and `eldoc-last-message' is not nil.
(setq eldoc-box--cleanup-timer
(run-with-timer eldoc-box-cleanup-interval nil #'eldoc-box--maybe-cleanup)))
multi-line-p)))
single-line-p)))
;;;; Eglot helper