branch: externals/company
commit e2b85dd9135a7849db42f58925b01a24b948e317
Author: Dmitry Gutov <[email protected]>
Commit: Dmitry Gutov <[email protected]>

    Fix grouped backend always returning non-nil
    
    Reported at https://www.reddit.com/r/emacs/comments/1flris4/comment/lo76onv/
---
 company.el         | 3 ++-
 test/core-tests.el | 4 ++++
 2 files changed, 6 insertions(+), 1 deletion(-)

diff --git a/company.el b/company.el
index 8e8b15cc5c..aba3249ef9 100644
--- a/company.el
+++ b/company.el
@@ -1447,7 +1447,8 @@ be recomputed when this value changes."
                          (not (eq t len))
                          (or (not len) (> new-len len))))
             (setq len new-len)))))
-    (unless backends-after-with
+    (when (and prefix
+               (not backends-after-with))
       (list prefix suffix len))))
 
 (defun company--multi-expand-common (backends min-length prefix suffix)
diff --git a/test/core-tests.el b/test/core-tests.el
index 0f8230f9ee..152e94c5a2 100644
--- a/test/core-tests.el
+++ b/test/core-tests.el
@@ -140,6 +140,10 @@
                    (candidates '("c" "d")))))))
     (should (equal (company-call-backend 'prefix) '("" nil 0)))))
 
+(ert-deftest company-multi-backend-none-applicable ()
+  (let ((company-backend (list #'ignore #'ignore)))
+    (should (null (company-call-backend 'prefix)))))
+
 (ert-deftest company-multi-backend-dispatches-separate-prefix-to-backends ()
   (let ((company-backend
          (list (lambda (command &optional arg &rest _r)

Reply via email to