From: Sean Whitton Date: Fri, 4 Oct 2024 00:19:40 +0000 (+0800) Subject: icomplete-completions: Revise computation of prospects-len X-Git-Url: http://git.eshelyaron.com/gitweb/?a=commitdiff_plain;h=bb5f8d9665a2dc46ed417223346a28a58b860d45;p=emacs.git 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) --- 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