]> git.eshelyaron.com Git - emacs.git/commitdiff
icomplete-completions: Revise computation of prospects-len
authorSean Whitton <spwhitton@spwhitton.name>
Fri, 4 Oct 2024 00:19:40 +0000 (08:19 +0800)
committerEshel Yaron <me@eshelyaron.com>
Sun, 6 Oct 2024 06:49:54 +0000 (08:49 +0200)
* 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

index ff55bb3d20780397629b5e4ce92d69236cfa46f5..f25d6d45546f3350e89e6830d7f1c2fbab1df3ec 100644 (file)
@@ -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