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

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

[elpa] externals/company 4ac63de5d8 06/24: Do a bit less consing


From: ELPA Syncer
Subject: [elpa] externals/company 4ac63de5d8 06/24: Do a bit less consing
Date: Mon, 6 Nov 2023 09:57:36 -0500 (EST)

branch: externals/company
commit 4ac63de5d899e6324c98023c5158dd0b5dd93c60
Author: Dmitry Gutov <dgutov@yandex.ru>
Commit: Dmitry Gutov <dgutov@yandex.ru>

    Do a bit less consing
---
 company.el | 13 +++++++++----
 1 file changed, 9 insertions(+), 4 deletions(-)

diff --git a/company.el b/company.el
index 6ce1ef9d8c..9788085c87 100644
--- a/company.el
+++ b/company.el
@@ -2821,12 +2821,14 @@ from the candidates list.")
         (to-chars (and to (ceiling (/ to (frame-char-width)))))
         (lstr (length str))
         spw-from spw-to
+        spw-from-prev
         front back)
     (while (and (< from-chars lstr)
                 (>
                  (setq spw-from
                        (company--string-pixel-width (substring str 0 
from-chars)))
                  from))
+      (setq spw-from-prev spw-from)
       (cl-decf from-chars))
     (if (>= from-chars lstr)
         (if to
@@ -2842,15 +2844,18 @@ from the candidates list.")
       (when (< spw-from from)
         (cl-incf from-chars)
         (setq front (propertize " " 'display
-                                `(space . (:width (,(- 
(company--string-pixel-width
-                                                        (substring str 0 
from-chars))
+                                `(space . (:width (,(- (or
+                                                        spw-from-prev
+                                                        
(company--string-pixel-width
+                                                         (substring str 0 
from-chars)))
                                                        from)))))))
       (unless spw-to (setq to-chars lstr))
       (when (and to (or (not spw-to) (< spw-to to)))
         (setq back (propertize " " 'display
                                `(space . (:width (,(- to
-                                                      
(company--string-pixel-width
-                                                       (substring str 0 
to-chars)))))))))
+                                                      (or
+                                                       spw-to
+                                                       
(company--string-pixel-width str)))))))))
       (concat front (substring str from-chars to-chars) back))))
 
 (defun company-safe-substring (str from &optional to)



reply via email to

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