branch: externals/ivy commit e8ac2e23ffccb23600c5a3883805560927a54202 Author: Basil L. Contovounesios <conto...@tcd.ie> Commit: Basil L. Contovounesios <conto...@tcd.ie>
Consider character widths when inserting prompt * ivy.el (ivy--insert-prompt): Use string-width instead of length when comparing prompt to window width. This avoids hscrolling the minibuffer, but does not fix imperfect line wrapping (#2869). --- ivy.el | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/ivy.el b/ivy.el index 256aeaa..a8d2682 100644 --- a/ivy.el +++ b/ivy.el @@ -3108,13 +3108,13 @@ parts beyond their respective faces `ivy-confirm-face' and (save-excursion (goto-char (point-min)) (delete-region (point-min) (minibuffer-prompt-end)) - (let ((len-n (length n-str)) - (len-d (length d-str)) + (let ((wid-n (string-width n-str)) + (wid-d (string-width d-str)) (ww (window-width))) (setq n-str - (cond ((> (+ len-n len-d) ww) + (cond ((> (+ wid-n wid-d) ww) (concat n-str "\n" d-str "\n")) - ((> (+ len-n len-d (length ivy-text)) ww) + ((> (+ wid-n wid-d (string-width ivy-text)) ww) (concat n-str d-str "\n")) (t (concat n-str d-str))))) @@ -3122,6 +3122,9 @@ parts beyond their respective faces `ivy-confirm-face' and (setq n-str (concat (funcall ivy-pre-prompt-function) n-str))) (when ivy-add-newline-after-prompt (setq n-str (concat n-str "\n"))) + ;; FIXME: This does not take character widths into account! + ;; Should ideally let the display engine wrap text, otherwise + ;; use `window-text-pixel-size'. See e.g. #2869. (let ((regex (format "\\([^\n]\\{%d\\}\\)[^\n]" (window-width)))) (while (string-match regex n-str) (setq n-str (replace-match