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

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

[nongnu] elpa/corfu-terminal 49016b317f 1/3: Account for left margin wid


From: ELPA Syncer
Subject: [nongnu] elpa/corfu-terminal 49016b317f 1/3: Account for left margin width while positioning popon
Date: Sun, 29 May 2022 07:58:11 -0400 (EDT)

branch: elpa/corfu-terminal
commit 49016b317fa64ee838b442e7c7e5a33731444a02
Author: Akib Azmain Turja <akib@disroot.org>
Commit: Akib Azmain Turja <akib@disroot.org>

    Account for left margin width while positioning popon
---
 corfu-terminal.el | 36 +++++++++---------------------------
 1 file changed, 9 insertions(+), 27 deletions(-)

diff --git a/corfu-terminal.el b/corfu-terminal.el
index b27b9b928d..b746502f28 100644
--- a/corfu-terminal.el
+++ b/corfu-terminal.el
@@ -99,19 +99,13 @@ definition in Corfu."
            (display-graphic-p))
       (funcall fn pos off width lines curr lo bar)
     (corfu-terminal--popup-hide #'ignore)  ; Hide the popup first.
-    (let* ((bar-width (if (display-graphic-p)
-                          (ceiling (* (default-font-width)
-                                      corfu-bar-width))
-                        (ceiling corfu-bar-width)))
-           (margin-left-width (if (display-graphic-p)
-                                  (ceiling (* (default-font-width)
-                                              corfu-left-margin-width))
-                                (ceiling corfu-left-margin-width)))
-           (margin-right-width (max (if (display-graphic-p)
-                                        (ceiling
-                                         (* (default-font-width)
-                                            corfu-right-margin-width))
-                                      (ceiling corfu-right-margin-width))
+    (let* ((bar-width (ceiling (* (default-font-width)
+                                  corfu-bar-width)))
+           (margin-left-width (ceiling (* (default-font-width)
+                                          corfu-left-margin-width)))
+           (margin-right-width (max (ceiling
+                                     (* (default-font-width)
+                                        corfu-right-margin-width))
                                     bar-width))
            (scroll-bar (when (< 0 bar-width)
                          (if (display-graphic-p)
@@ -151,21 +145,9 @@ definition in Corfu."
                           (car corfu-terminal--last-position)
                         (let ((pos (popon-x-y-at-pos pos)))
                           (cons
-                           ;; NOTE: `window-max-chars-per-line' is probably
-                           ;; better.
                            (max
-                            (min (- (car pos) off)
-                                 (- (window-width)
-                                    (line-number-display-width)
-                                    (if (display-graphic-p)
-                                        (let ((fringes (window-fringes)))
-                                          (+ (/ (+ (car fringes)
-                                                   (cadr fringes))
-                                                (frame-char-width))
-                                             (if (zerop (cadr fringes))
-                                                 1
-                                               0)))
-                                      (1+ (if (zerop (window-hscroll)) 0 1)))
+                            (min (- (car pos) (+ off margin-left-width))
+                                 (- (window-max-chars-per-line)
                                     corfu-terminal-position-right-margin
                                     popon-width))
                             0)



reply via email to

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