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

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

[elpa] externals/company 7b849c0c6f 18/24: Mo tests and some fixes


From: ELPA Syncer
Subject: [elpa] externals/company 7b849c0c6f 18/24: Mo tests and some fixes
Date: Tue, 27 Aug 2024 00:57:44 -0400 (EDT)

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

    Mo tests and some fixes
---
 company.el         |  3 ++-
 test/core-tests.el | 52 ++++++++++++++++++++++++++++++++++++++++++++++++++++
 2 files changed, 54 insertions(+), 1 deletion(-)

diff --git a/company.el b/company.el
index f7182dae85..364652f455 100644
--- a/company.el
+++ b/company.el
@@ -1472,7 +1472,7 @@ be recomputed when this value changes."
                               (aref (car (nth 2 tuple)) beg)))
                  (cl-incf beg))
                (while (and (< end max-end)
-                           (= (aref prefix (- bslen end 1))
+                           (= (aref suffix (- bslen end 1))
                               (aref (cdr (nth 2 tuple))
                                     (- rep-suffix-len end 1))))
                  (cl-incf end))
@@ -1495,6 +1495,7 @@ be recomputed when this value changes."
        ;; change the buffer contents first, then fetch `candidates' for each,
        ;; and revert at the end.  Might be error-prone.
        (and
+        choice
         (cl-every
          (lambda (replacement)
            (and
diff --git a/test/core-tests.el b/test/core-tests.el
index 45ea312171..d27be8a16d 100644
--- a/test/core-tests.el
+++ b/test/core-tests.el
@@ -357,6 +357,58 @@
                                   (car (member "a1b" candidates))
                                   "aa" "bcd")))))
 
+(ert-deftest company-multi-backend-combines-expand-common ()
+  (let* ((one (lambda (command &rest _args)
+                (cl-case command
+                  (prefix '("a" ""))
+                  (expand-common (cons "ab" "")))))
+         (two (lambda (command &rest _args)
+                (cl-case command
+                  (prefix '("aa" "bcd"))
+                  (expand-common (cons "aab" "bcd")))))
+         (tri (lambda (command &rest _args)
+                (cl-case command
+                  (prefix '("aa" "bcd"))
+                  (expand-common 'no-match))))
+         (company-backend (list one two tri))
+         (company-point (point)))
+    (company-call-backend 'set-min-prefix 1)
+    (should
+     (equal '("aab" . "bcd")
+            (company-call-backend 'expand-common "aa" "bcd")))))
+
+(ert-deftest company-multi-backend-expand-common-returns-no-match ()
+  (let* ((one (lambda (command &rest _args)
+                (cl-case command
+                  (prefix '("a" ""))
+                  (expand-common 'no-match))))
+         (two (lambda (command &rest _args)
+                (cl-case command
+                  (prefix '("aa" "bcd"))
+                  (expand-common 'no-match))))
+         (company-backend (list one two))
+         (company-point (point)))
+    (company-call-backend 'set-min-prefix 1)
+    (should
+     (equal 'no-match
+            (company-call-backend 'expand-common "aa" "bcd")))))
+
+(ert-deftest company-multi-backend-expand-common-keeps-current ()
+  (let* ((one (lambda (command &rest _args)
+                (cl-case command
+                  (prefix '("a" ""))
+                  (expand-common (cons "ab" "")))))
+         (two (lambda (command &rest _args)
+                (cl-case command
+                  (prefix '("a" ""))
+                  (expand-common (cons "ac" "")))))
+         (company-backend (list one two))
+         (company-point (point)))
+    (company-call-backend 'set-min-prefix 1)
+    (should
+     (equal '("a" . "")
+            (company-call-backend 'expand-common "a" "")))))
+
 (ert-deftest company-begin-backend-failure-doesnt-break-company-backends ()
   (with-temp-buffer
     (insert "a")



reply via email to

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