From d0443e0215196b1576800ae1d5f0f5357a8a8dad Mon Sep 17 00:00:00 2001 From: Gregory Heytings Date: Sat, 31 Dec 2022 14:50:13 +0000 Subject: [PATCH] Fix handling of completions-header-format * lisp/minibuffer.el (display-completion-list): Insert an invisible line when completions-header-format is not a string (in particular, nil) or is an empty string. Fixes bug#60411. Also, do not use completions-header-format when it is not a string. --- lisp/minibuffer.el | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/lisp/minibuffer.el b/lisp/minibuffer.el index 7a720cf2c0..6c7413c555 100644 --- a/lisp/minibuffer.el +++ b/lisp/minibuffer.el @@ -2275,8 +2275,14 @@ display-completion-list (with-current-buffer standard-output (goto-char (point-max)) - (when completions-header-format + (when (stringp completions-header-format) (insert (format completions-header-format (length completions)))) + (when (or (not (stringp completions-header-format)) + (string= completions-header-format "")) + ;; Insert an invisible line, otherwise the first call to + ;; 'minibuffer-next-completion' might select the second + ;; completion candidate. See bug#60411. + (insert (propertize "\n" 'invisible t))) (completion--insert-strings completions group-fun))) (run-hooks 'completion-setup-hook) -- 2.39.0