]> code.delx.au - gnu-emacs-elpa/commitdiff
company--multi-backend-adapter-candidates: bind backend locally
authorDmitry Gutov <dgutov@yandex.ru>
Fri, 4 Apr 2014 12:53:42 +0000 (15:53 +0300)
committerDmitry Gutov <dgutov@yandex.ru>
Fri, 4 Apr 2014 12:55:18 +0000 (15:55 +0300)
Fixes #89

company-tests.el
company.el

index c2ea35bb2391a43519a3308d30f023c0c9818cbb..9e678af343074a7f1a9b37ab9c4689942d4ea594 100644 (file)
 
 (ert-deftest company-multi-backend-remembers-candidate-backend ()
   (let ((company-backend
-         (list (lambda (command &optional arg &rest ignore)
+         (list (lambda (command &optional arg)
                  (case command
                    (ignore-case nil)
                    (annotation "1")
                    (candidates '("a" "c"))
                    (post-completion "13")))
-               (lambda (command &optional arg &rest ignore)
+               (lambda (command &optional arg)
                  (case command
                    (ignore-case t)
                    (annotation "2")
                    (candidates '("b" "d"))
-                   (post-completion "42"))))))
+                   (post-completion "42")))
+               (lambda (command &optional arg)
+                 (case command
+                   (annotation "3")
+                   (candidates '("e"))
+                   (post-completion "74"))))))
     (let ((candidates (company-calculate-candidates nil)))
-      (should (equal candidates '("a" "b" "c" "d")))
+      (should (equal candidates '("a" "b" "c" "d" "e")))
       (should (equal t (company-call-backend 'ignore-case)))
       (should (equal "1" (company-call-backend 'annotation (nth 0 candidates))))
       (should (equal "2" (company-call-backend 'annotation (nth 1 candidates))))
       (should (equal "13" (company-call-backend 'post-completion (nth 2 candidates))))
-      (should (equal "42" (company-call-backend 'post-completion (nth 3 candidates)))))))
+      (should (equal "42" (company-call-backend 'post-completion (nth 3 candidates))))
+      (should (equal "3" (company-call-backend 'annotation (nth 4 candidates))))
+      (should (equal "74" (company-call-backend 'post-completion (nth 4 candidates)))))))
 
 (ert-deftest company-multi-backend-handles-keyword-with ()
   (let ((primo (lambda (command &optional arg)
index 24b00cb21974d60b18e05e3f8f656fc10b788f7e..1c255bf8b7004a0e3904bb17591cb311b95f9fe1 100644 (file)
@@ -859,12 +859,12 @@ means that `company-mode' is always turned on except in `message-mode' buffers."
                      when (equal (funcall backend 'prefix)
                                  prefix)
                      collect (cons (funcall backend 'candidates prefix)
-                                   (lambda (candidates)
-                                     (mapcar
-                                      (lambda (str)
-                                        (propertize str 'company-backend
-                                                    backend))
-                                      candidates))))))
+                                   (let ((b backend))
+                                     (lambda (candidates)
+                                       (mapcar
+                                        (lambda (str)
+                                          (propertize str 'company-backend b))
+                                        candidates)))))))
     (when (equal (funcall (car backends) 'prefix) prefix)
       ;; Small perf optimization: don't tag the candidates received
       ;; from the first backend in the group.