From 98cfa9bf6d9ec23573365031b3734fb9c2965dd5 Mon Sep 17 00:00:00 2001 From: Sean Whitton Date: Fri, 4 Oct 2024 08:19:40 +0800 Subject: [PATCH] icomplete-completions: Compute prospects-len more efficiently * lisp/icomplete.el (icomplete-completions): Avoid calling string-width on the entire buffer-string when computing prospects-len (bug#72826). --- lisp/icomplete.el | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/lisp/icomplete.el b/lisp/icomplete.el index 2ea5e36fa88..9497b46c6cf 100644 --- a/lisp/icomplete.el +++ b/lisp/icomplete.el @@ -1007,7 +1007,12 @@ icomplete-completions (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.45.2