From bb5f8d9665a2dc46ed417223346a28a58b860d45 Mon Sep 17 00:00:00 2001 From: Sean Whitton Date: Fri, 4 Oct 2024 08:19:40 +0800 Subject: [PATCH] icomplete-completions: Revise computation of prospects-len * lisp/icomplete.el (icomplete-completions): Revise computation of prospects-len (i) to avoid calling string-width on the entire buffer-string, which could be slow; and (ii) to better handle minibuffer prompts with embedded newlines (bug#72826). (cherry picked from commit a96954b982ddd441ac943bfa48015fb4775c00cb) --- lisp/icomplete.el | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/lisp/icomplete.el b/lisp/icomplete.el index ff55bb3d207..f25d6d45546 100644 --- a/lisp/icomplete.el +++ b/lisp/icomplete.el @@ -978,7 +978,12 @@ matches exist." (or determ (concat open-bracket close-bracket))) (string-width icomplete-separator) (+ 2 (string-width ellipsis)) ;; take {…} into account - (string-width (buffer-string)))) + (string-width + (buffer-substring + (save-excursion + (goto-char (icomplete--field-beg)) + (pos-bol)) + (icomplete--field-end))))) (prospects-max ;; Max total length to use, including the minibuffer content. (* (+ icomplete-prospects-height -- 2.39.2