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

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

[elpa] externals/company a79bfd7cea 19/24: Fix multi-backend completion


From: ELPA Syncer
Subject: [elpa] externals/company a79bfd7cea 19/24: Fix multi-backend completion right after a trigger char
Date: Tue, 27 Aug 2024 00:57:44 -0400 (EDT)

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

    Fix multi-backend completion right after a trigger char
---
 company.el         |  6 ++++--
 test/core-tests.el | 12 ++++++++++++
 2 files changed, 16 insertions(+), 2 deletions(-)

diff --git a/company.el b/company.el
index 364652f455..3138665058 100644
--- a/company.el
+++ b/company.el
@@ -1419,8 +1419,10 @@ be recomputed when this value changes."
           (or (not backends-after-with)
               (unless (memq backend backends-after-with)
                 (setq backends-after-with nil)))
-          (when (> (length (company--prefix-str entity))
-                   (length prefix))
+          (when (or
+                 (null prefix)
+                 (> (length (company--prefix-str entity))
+                    (length prefix)))
             (setq prefix (company--prefix-str entity)))
           (when (> (length (company--suffix-str entity))
                    (length suffix))
diff --git a/test/core-tests.el b/test/core-tests.el
index d27be8a16d..0f8230f9ee 100644
--- a/test/core-tests.el
+++ b/test/core-tests.el
@@ -128,6 +128,18 @@
     (company-call-backend 'set-min-prefix 1)
     (should (equal (company-call-backend 'candidates "z") '("a" "b" "c" 
"d")))))
 
+(ert-deftest company-multi-backend-with-empty-prefixes ()
+  (let ((company-backend
+         (list (lambda (command &optional _ &rest _r)
+                 (cl-case command
+                   (prefix "")
+                   (candidates '("a" "b"))))
+               (lambda (command &optional _ &rest _r)
+                 (cl-case command
+                   (prefix "")
+                   (candidates '("c" "d")))))))
+    (should (equal (company-call-backend 'prefix) '("" nil 0)))))
+
 (ert-deftest company-multi-backend-dispatches-separate-prefix-to-backends ()
   (let ((company-backend
          (list (lambda (command &optional arg &rest _r)



reply via email to

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