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

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

[nongnu] elpa/corfu-popup 4ce83ab8bd 19/26: Fix #3: Keep popon within th


From: ELPA Syncer
Subject: [nongnu] elpa/corfu-popup 4ce83ab8bd 19/26: Fix #3: Keep popon within the visible part of window
Date: Sun, 22 May 2022 12:58:16 -0400 (EDT)

branch: elpa/corfu-popup
commit 4ce83ab8bdd67f11f43d3b27e8b255ecd00f6853
Author: Akib Azmain Turja <akib@disroot.org>
Commit: Akib Azmain Turja <akib@disroot.org>

    Fix #3: Keep popon within the visible part of window
---
 corfu-popup.el | 33 +++++++++++++++++++++++----------
 1 file changed, 23 insertions(+), 10 deletions(-)

diff --git a/corfu-popup.el b/corfu-popup.el
index 43983dbe81..703dad8f96 100644
--- a/corfu-popup.el
+++ b/corfu-popup.el
@@ -106,17 +106,33 @@ Show a vertical scroll bar of size BAR + 1 from LOth 
line."
                                          `(space
                                            :width (,margin-right-width)))
                            (make-string margin-right-width ? ))))
+         (popon-width (if (display-graphic-p)
+                          (+ width (round (/ (+ margin-left-width
+                                                margin-right-width)
+                                             (frame-char-width))))
+                        (+ width margin-left-width margin-right-width)))
          (popon-pos (if (equal (cdr corfu-popup--last-position)
                                (list pos (window-start)
                                      (buffer-modified-tick)))
                         (car corfu-popup--last-position)
                       (let ((pos (popon-x-y-at-pos pos)))
-                        (cons (max 0 (- (car pos) off))
-                              (if (and (< (floor (window-screen-lines))
-                                          (+ (cdr pos) (length lines)))
-                                       (>= (cdr pos) (length lines)))
-                                  (- (cdr pos) (length lines))
-                                (1+ (cdr pos))))))))
+                        (cons
+                         (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)))
+                                    (1+ (if (zerop (window-hscroll)) 0 1)))
+                                  popon-width))
+                          0)
+                         (if (and (< (floor (window-screen-lines))
+                                     (+ (cdr pos) (length lines)))
+                                  (>= (cdr pos) (length lines)))
+                             (- (cdr pos) (length lines))
+                           (1+ (cdr pos))))))))
     (setq corfu-popup--last-position
           (list popon-pos pos (window-start) (buffer-modified-tick)))
     (setq corfu-popup--popon
@@ -139,10 +155,7 @@ Show a vertical scroll bar of size BAR + 1 from LOth line."
                   str))
               lines)
              "\n")
-            (if (display-graphic-p)
-                (+ width (round (/ (+ margin-left-width margin-right-width)
-                                   (frame-char-width))))
-              (+ width margin-left-width margin-right-width)))
+            popon-width)
            popon-pos))
     nil))
 



reply via email to

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