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

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

[nongnu] elpa/corfu-popup 323a92088c 20/26: Fix popon breaking when righ


From: ELPA Syncer
Subject: [nongnu] elpa/corfu-popup 323a92088c 20/26: Fix popon breaking when right fringe is zero on graphical display (#3)
Date: Sun, 22 May 2022 12:58:16 -0400 (EDT)

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

    Fix popon breaking when right fringe is zero on graphical display (#3)
---
 corfu-popup.el | 26 ++++++++++++++++++++++----
 1 file changed, 22 insertions(+), 4 deletions(-)

diff --git a/corfu-popup.el b/corfu-popup.el
index 703dad8f96..156127fbad 100644
--- a/corfu-popup.el
+++ b/corfu-popup.el
@@ -48,6 +48,18 @@
   :link '(url-link "https://codeberg.org/akib/emacs-corfu-popup";)
   :prefix "corfu-popup-")
 
+(defcustom corfu-popup-position-right-margin 0
+  "Number of columns of margin at the right of window.
+
+Always keep the popup this many columns away from the right edge of the
+window.
+
+Note: If the popup breaks or crosses the right edge of window, you may set
+this variable to warkaround it.  But remember, that's a *bug*, so if that
+ever happens to you please report the issue at
+https://codeberg.org/akib/emacs-corfu-popup/issues.";
+  :type 'integer)
+
 (declare-function corfu--auto-tick "corfu") ;; OK, byte-compiler?
 
 (defvar corfu-popup--popon nil
@@ -112,7 +124,7 @@ Show a vertical scroll bar of size BAR + 1 from LOth line."
                                              (frame-char-width))))
                         (+ width margin-left-width margin-right-width)))
          (popon-pos (if (equal (cdr corfu-popup--last-position)
-                               (list pos (window-start)
+                               (list pos popon-width (window-start)
                                      (buffer-modified-tick)))
                         (car corfu-popup--last-position)
                       (let ((pos (popon-x-y-at-pos pos)))
@@ -123,9 +135,14 @@ Show a vertical scroll bar of size BAR + 1 from LOth line."
                                   (line-number-display-width)
                                   (if (display-graphic-p)
                                       (let ((fringes (window-fringes)))
-                                        (/ (+ (car fringes) (cadr fringes))
-                                           (frame-char-width)))
+                                        (+ (/ (+ (car fringes)
+                                                 (cadr fringes))
+                                              (frame-char-width))
+                                           (if (zerop (cadr fringes))
+                                               1
+                                             0)))
                                     (1+ (if (zerop (window-hscroll)) 0 1)))
+                                  corfu-popup-position-right-margin
                                   popon-width))
                           0)
                          (if (and (< (floor (window-screen-lines))
@@ -134,7 +151,8 @@ Show a vertical scroll bar of size BAR + 1 from LOth line."
                              (- (cdr pos) (length lines))
                            (1+ (cdr pos))))))))
     (setq corfu-popup--last-position
-          (list popon-pos pos (window-start) (buffer-modified-tick)))
+          (list popon-pos pos popon-width (window-start)
+                (buffer-modified-tick)))
     (setq corfu-popup--popon
           (popon-create
            (cons



reply via email to

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