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

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

[elpa] externals/company d8f18dcf06 12/24: company--expand-common: Don't


From: ELPA Syncer
Subject: [elpa] externals/company d8f18dcf06 12/24: company--expand-common: Don't rely on company-common
Date: Tue, 27 Aug 2024 00:57:43 -0400 (EDT)

branch: externals/company
commit d8f18dcf0608b661f1b7b9f3db91460b66370d2d
Author: Dmitry Gutov <dmitry@gutov.dev>
Commit: Dmitry Gutov <dmitry@gutov.dev>

    company--expand-common: Don't rely on company-common
---
 company.el | 17 +++++++++--------
 1 file changed, 9 insertions(+), 8 deletions(-)

diff --git a/company.el b/company.el
index 91377c05c9..0b8d26b658 100644
--- a/company.el
+++ b/company.el
@@ -3067,7 +3067,12 @@ For use in the `select-mouse' frontend action.  
`let'-bound.")
   (let ((expansion (company-call-backend 'expand-common prefix suffix)))
     (unless expansion
       ;; Backend doesn't implement this, try emulating.
-      (let* ((max-len (when (and company-common
+      (let* (;; Assuming that boundaries don't vary between completions here.
+             ;; If they do, the backend should have a custom `expand-common'.
+             (boundaries-prefix (car (company--boundaries)))
+             (trycmp (try-completion boundaries-prefix candidates))
+             (common (if (eq trycmp t) (car candidates) trycmp))
+             (max-len (when (and common
                                  (cl-every (lambda (s) (string-suffix-p suffix 
s))
                                            candidates))
                         (-
@@ -3075,13 +3080,9 @@ For use in the `select-mouse' frontend action.  
`let'-bound.")
                                 (mapcar #'length candidates))
                          (length suffix))))
              (common (if max-len
-                         (substring company-common 0
-                                    (min max-len (length company-common)))
-                       company-common))
-             ;; We're making an assumption that boundaries don't vary
-             ;; between completions here. If they do, the backend should
-             ;; have a custom implementation for `expand-common'.
-             (boundaries-prefix (car (company--boundaries))))
+                         (substring common 0
+                                    (min max-len (length common)))
+                       common)))
         (setq expansion (cons (if (string-prefix-p boundaries-prefix
                                                    common
                                                    t)



reply via email to

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