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

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

[elpa] externals/corfu 9aa922d 01/16: Use `vertical-motion` instead of `


From: Protesilaos Stavrou
Subject: [elpa] externals/corfu 9aa922d 01/16: Use `vertical-motion` instead of `forward-line`
Date: Wed, 28 Apr 2021 14:20:01 -0400 (EDT)

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

    Use `vertical-motion` instead of `forward-line`
    
    Partial fix of #15
---
 corfu.el | 14 +++++++-------
 1 file changed, 7 insertions(+), 7 deletions(-)

diff --git a/corfu.el b/corfu.el
index 3149744..1a96dd8 100644
--- a/corfu.el
+++ b/corfu.el
@@ -204,8 +204,8 @@ If `line-spacing/=nil' or in text-mode, the background 
color is used instead.")
            (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))))
+           (ypos (count-screen-lines (save-excursion (move-to-window-line 0) 
(point))
+                                     (point)))
            (count (length lines))
            (row 0) (width) (formatted) (beg))
       (if (< rest-width (car corfu-width-limits))
@@ -216,12 +216,12 @@ If `line-spacing/=nil' or in text-mode, the background 
color is used instead.")
               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 2)))
-                        (- count) 1))
+      (vertical-motion (if (and (< count ypos)
+                              (>= count (- (floor (window-pixel-height) (cdr 
size)) ypos 1)))
+                         (- count) 1))
       (setq beg (point))
       (when (save-excursion
-              (forward-line 1)
+              (vertical-motion 1)
               (/= (point) (line-beginning-position)))
         (push #(" \n" 0 1 (cursor t)) formatted))
       (dolist (line lines)
@@ -244,7 +244,7 @@ If `line-spacing/=nil' or in text-mode, the background 
color is used instead.")
                  "\n")
                 formatted)
           (setq row (1+ row))
-          (forward-line 1)))
+          (vertical-motion 1)))
       (let ((ov (make-overlay beg (point))))
         (overlay-put ov 'priority 900)
         (overlay-put ov 'window (selected-window))



reply via email to

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