branch: externals/corfu
commit 51f3ad71bd9f199aa20ba0ab19baf883bc31fc8a
Author: Daniel Mendler <m...@daniel-mendler.de>
Commit: Daniel Mendler <m...@daniel-mendler.de>

    corfu-quick: Ensure that popup does not move (Fix #566)
---
 extensions/corfu-quick.el | 30 +++++++++++-------------------
 1 file changed, 11 insertions(+), 19 deletions(-)

diff --git a/extensions/corfu-quick.el b/extensions/corfu-quick.el
index dd87b5f6e9..4a98f01fd6 100644
--- a/extensions/corfu-quick.el
+++ b/extensions/corfu-quick.el
@@ -80,10 +80,10 @@ TWO is non-nil if two keys should be displayed."
           (cond
            ((eq first two)
             (list
-             (concat " " (propertize (char-to-string second) 'face 
'corfu-quick1))
+             (propertize (char-to-string second) 'face 'corfu-quick1)
              (cons second (+ corfu--scroll idx))))
            (two
-            (list "  "))
+            (list ""))
            (t
             (list
              (concat (propertize (char-to-string first) 'face 'corfu-quick1)
@@ -91,31 +91,23 @@ TWO is non-nil if two keys should be displayed."
              (cons first (list first))))))
       (let ((first (elt corfu-quick1 (mod idx fst))))
         (if two
-            (list "  ")
+            (list "")
           (list
-           (concat (propertize (char-to-string first) 'face 'corfu-quick1) " ")
+           (propertize (char-to-string first) 'face 'corfu-quick1)
            (cons first (+ corfu--scroll idx))))))))
 
 (defun corfu-quick--read (&optional first)
   "Read quick key given FIRST pressed key."
   (cl-letf* ((list nil)
-             (space1 (propertize " " 'display
-                                 `(space :width
-                                         (+ 0.5 (,(alist-get
-                                                   'child-frame-border-width
-                                                   
corfu--frame-parameters))))))
-             (space2 #(" " 0 1 (display (space :width 0.5))))
-             (orig (symbol-function #'corfu--affixate))
-             ((symbol-function #'corfu--affixate)
+             (orig (symbol-function #'corfu--format-candidates))
+             ((symbol-function #'corfu--format-candidates)
               (lambda (cands)
-                (setq cands (cdr (funcall orig cands)))
-                (cl-loop for cand in cands for index from 0 do
+                (setq cands (funcall orig cands))
+                (cl-loop for cand in-ref (nth 2 cands) for index from 0 do
                          (pcase-let ((`(,keys . ,events) (corfu-quick--keys 
first index)))
-                           (setq list (nconc events list))
-                           (setf (cadr cand) (concat space1 (propertize " " 
'display keys) space2))))
-                (cons t cands)))
-             ;; Increase minimum width to avoid odd jumping
-             (corfu-min-width (+ 3 corfu-min-width)))
+                           (setf list (nconc events list)
+                                 cand (concat keys (substring cand (min 
(length cand) (length keys)))))))
+                cands)))
     (corfu--candidates-popup
      (posn-at-point (+ (car completion-in-region--data) (length corfu--base))))
     (alist-get (read-key) list)))

Reply via email to