]> code.delx.au - gnu-emacs-elpa/commitdiff
company--multi-backend-adapter: Use each respective backend's prefix
authorDmitry Gutov <dgutov@yandex.ru>
Tue, 16 Apr 2013 02:24:53 +0000 (06:24 +0400)
committerDmitry Gutov <dgutov@yandex.ru>
Tue, 16 Apr 2013 02:32:51 +0000 (06:32 +0400)
NEWS.md
company-tests.el
company.el

diff --git a/NEWS.md b/NEWS.md
index 91064a45e54faa3d1e3ec60686c0bc2c474bfd5d..b63d5ed5c494240b5c72f1e2fd789bade14b51af 100644 (file)
--- a/NEWS.md
+++ b/NEWS.md
@@ -2,6 +2,9 @@
 
 ## Next
 
+* Candidates from grouped back-ends are retrieved more accurately: each
+  `candidates` command receives in the second argument the respective value the
+  back-end returned to the `prefix` command.
 * `company-auto-complete` is disabled by default.
 * `company-auto-complete-chars` default value includes fewer syntax classes.
 * In expanded function calls, arguments skipped by the user default to "argN".
index 309d8f1f8b4832a64fb8f562318488dd927f0544..657486b096a88dc2573801c2a5960e05d544b2f2 100644 (file)
       (should (null company-candidates))
       (should (null (company-explicit-action-p))))))
 
+(ert-deftest company-multi-backend-adapter-uses-respective-prefixes ()
+  ;; And ignores the second argument.
+  (let ((company-backend
+         (list (lambda (command &optional arg)
+                 (case command
+                   (prefix "bar")
+                   (candidates (mapcar (lambda (tail) (concat arg "-" tail))
+                                       '("a" "b" "c")))))
+               (lambda (command &optional arg)
+                 (case command
+                   (prefix "foo-bar")
+                   (candidates (mapcar (lambda (tail) (concat arg "-" tail))
+                                       '("d" "e"))))))))
+    (should (equal (sort '("bar-a" "bar-b" "bar-c" "foo-bar-d" "foo-bar-e")
+                         'string<)
+                   (company-call-backend 'candidates "hubba-hubba")))))
+
+;; Pseudo-Tooltip
+
 (ert-deftest company-pseudo-tooltip-does-not-get-displaced ()
   (with-temp-buffer
     (save-window-excursion
index 9f13518f0ebb70957e0b588706453c05e6dcfbde..3fa83534aab996420dc091b88be48c45b6b51c2c 100644 (file)
@@ -658,9 +658,9 @@ keymap during active completions (`company-active-map'):
     (case command
       (candidates
        (loop for backend in backends
-             when (equal (funcall backend 'prefix)
-                         (car args))
-             append (apply backend 'candidates args)))
+             for prefix = (funcall backend 'prefix)
+             when prefix
+             append (funcall backend 'candidates prefix)))
       (sorted nil)
       (duplicates t)
       (otherwise