emacs-elpa-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[elpa] externals/corfu 2b426a1 1/2: Pass beg+base as position to `corfu-


From: Protesilaos Stavrou
Subject: [elpa] externals/corfu 2b426a1 1/2: Pass beg+base as position to `corfu--popup`
Date: Tue, 20 Apr 2021 22:04:01 -0400 (EDT)

branch: externals/corfu
commit 2b426a1d8926da932b7702ceb9754a726bd0e705
Author: Daniel Mendler <mail@daniel-mendler.de>
Commit: Daniel Mendler <mail@daniel-mendler.de>

    Pass beg+base as position to `corfu--popup`
---
 corfu.el | 57 +++++++++++++++++++++++++++++----------------------------
 1 file changed, 29 insertions(+), 28 deletions(-)

diff --git a/corfu.el b/corfu.el
index f225816..a1cbc9b 100644
--- a/corfu.el
+++ b/corfu.el
@@ -176,33 +176,34 @@ If `line-spacing/=nil' or in text-mode, the background 
color is used instead.")
              :foreground ,(face-attribute fg :foreground)))))
 
 (defun corfu--popup (pos idx lo bar lines)
-  "Show LINES as popup at POS, with IDX highlighted and scrollbar between LO 
and LO+BAR."
-  (let* ((size (corfu--char-size))
-         ;; XXX Deactivate fancy border on terminal or if line-spacing is used
-         (fancy (and (not line-spacing) (display-graphic-p)))
-         (lborder-curr (corfu--border (car size) (cdr size) 1 'corfu-border 
'corfu-current))
-         (rborder-curr (corfu--border (car size) (cdr size) -1 'corfu-border 
'corfu-current))
-         (rbar-curr (corfu--border (car size) (cdr size) (- (ceiling (car 
size) 3))
-                                   'corfu-bar 'corfu-current))
-         (lborder (corfu--border (car size) (cdr size) 1 'corfu-border 
'corfu-background))
-         (rborder (corfu--border (car size) (cdr size) -1 'corfu-border 
'corfu-background))
-         (rbar (corfu--border (car size) (cdr size) (- (ceiling (car size) 3))
-                              'corfu-bar 'corfu-background))
-         (col (+ (- pos (line-beginning-position)) corfu--base))
-         (max-width (min (cdr corfu-width-limits) (/ (window-total-width) 2)))
-         (rest-width (- (window-total-width) col 4))
-         (ypos (- (line-number-at-pos pos)
-                  (save-excursion (move-to-window-line 0) 
(line-number-at-pos))))
-         (count (length lines))
-         (row 0) (width) (formatted) (beg))
-    (if (< rest-width (car corfu-width-limits))
-        (setq lines (mapcar (lambda (x) (truncate-string-to-width x 
max-width)) lines)
-              width (apply #'max (car corfu-width-limits) (mapcar 
#'string-width lines))
-              col (max 0 (- col width 2)))
-      (setq max-width (min rest-width max-width)
-            lines (mapcar (lambda (x) (truncate-string-to-width x max-width)) 
lines)
-            width (apply #'max (car corfu-width-limits) (mapcar #'string-width 
lines))))
-    (save-excursion
+  "Show LINES as popup at POS, with IDX highlighted and scrollbar from LO to 
LO+BAR."
+  (save-excursion
+    (goto-char pos)
+    (let* ((size (corfu--char-size))
+           ;; XXX Deactivate fancy border on terminal or if line-spacing is 
used
+           (fancy (and (not line-spacing) (display-graphic-p)))
+           (lborder-curr (corfu--border (car size) (cdr size) 1 'corfu-border 
'corfu-current))
+           (rborder-curr (corfu--border (car size) (cdr size) -1 'corfu-border 
'corfu-current))
+           (rbar-curr (corfu--border (car size) (cdr size) (- (ceiling (car 
size) 3))
+                                     'corfu-bar 'corfu-current))
+           (lborder (corfu--border (car size) (cdr size) 1 'corfu-border 
'corfu-background))
+           (rborder (corfu--border (car size) (cdr size) -1 'corfu-border 
'corfu-background))
+           (rbar (corfu--border (car size) (cdr size) (- (ceiling (car size) 
3))
+                                'corfu-bar 'corfu-background))
+           (max-width (min (cdr corfu-width-limits) (/ (window-total-width) 
2)))
+           (col (- pos (line-beginning-position)))
+           (rest-width (- (window-total-width) col 4))
+           (ypos (- (line-number-at-pos)
+                    (save-excursion (move-to-window-line 0) 
(line-number-at-pos))))
+           (count (length lines))
+           (row 0) (width) (formatted) (beg))
+      (if (< rest-width (car corfu-width-limits))
+          (setq lines (mapcar (lambda (x) (truncate-string-to-width x 
max-width)) lines)
+                width (apply #'max (car corfu-width-limits) (mapcar 
#'string-width lines))
+                col (max 0 (- col width 2)))
+        (setq max-width (min rest-width max-width)
+              lines (mapcar (lambda (x) (truncate-string-to-width x 
max-width)) lines)
+              width (apply #'max (car corfu-width-limits) (mapcar 
#'string-width lines))))
       (beginning-of-line)
       (forward-line (if (and (< count ypos)
                              (>= count (- (floor (window-pixel-height) (cdr 
size)) ypos 1)))
@@ -414,7 +415,7 @@ If `line-spacing/=nil' or in text-mode, the background 
color is used instead.")
           (setq lo (max 1 lo)))
         (when (/= last corfu--total)
           (setq lo (min (- corfu-count bar 2) lo)))
-        (corfu--popup beg curr (and (> corfu--total corfu-count) lo) bar 
ann-cands)))
+        (corfu--popup (+ beg corfu--base) curr (and (> corfu--total 
corfu-count) lo) bar ann-cands)))
      ;; When after `completion-at-point/corfu-complete', no further completion 
is possible and the
      ;; current string is a valid match, exit with status 'finished.
      ((and (memq this-command '(corfu-complete completion-at-point))



reply via email to

[Prev in Thread] Current Thread [Next in Thread]