]> code.delx.au - gnu-emacs-elpa/commitdiff
company--continue-failed: Don't burp on `stop'
authorDmitry Gutov <dgutov@yandex.ru>
Thu, 8 Jan 2015 17:09:06 +0000 (20:09 +0300)
committerDmitry Gutov <dgutov@yandex.ru>
Thu, 8 Jan 2015 17:09:06 +0000 (20:09 +0300)
#273

company.el
test/core-tests.el

index c53d7ae37208f2b50d086f85ce580c13a674c65a..e6bebbf929b90d53aaa8187b01159024a8614a7d 100644 (file)
@@ -1366,6 +1366,7 @@ from the rest of the back-ends in the group, if any, will be left at the end."
      ((and (or (not (company-require-match-p))
                ;; Don't require match if the new prefix
                ;; doesn't continue the old one, and the latter was a match.
+               (not (stringp new-prefix))
                (<= (length new-prefix) (length company-prefix)))
            (member company-prefix company-candidates))
       ;; Last input was a success,
index 0ff691e4ba3881cb7b376eabeccb80c742cdd6f4..90ce69c921fa3c49e2a8317ffdd08c91cb28b703 100644 (file)
       (should (eq nil company-candidates-length))
       (should (eq 4 (point))))))
 
-(ert-deftest company-dont-require-match-if-old-prefix-ended-and-was-a-match ()
+(ert-deftest company-dont-require-match-if-was-a-match-and-old-prefix-ended ()
   (with-temp-buffer
     (insert "ab")
     (company-mode)
     (let (company-frontends
-          (company-require-match 'company-explicit-action-p)
+          (company-require-match t)
           (company-backends
            (list (lambda (command &optional _)
                    (cl-case command
       (should (null company-candidates-length))
       (should (eq 4 (point))))))
 
+(ert-deftest company-dont-require-match-if-was-a-match-and-new-prefix-is-stop ()
+  (with-temp-buffer
+    (company-mode)
+    (insert "c")
+    (let (company-frontends
+          (company-require-match t)
+          (company-backends
+           (list (lambda (command &optional _)
+                   (cl-case command
+                     (prefix (if (> (point) 2)
+                                 'stop
+                               (buffer-substring (point-min) (point))))
+                     (candidates '("a" "b" "c")))))))
+      (let (this-command)
+        (company-complete))
+      (should (eq 3 company-candidates-length))
+      (let ((last-command-event ?e))
+        (company-call 'self-insert-command 1))
+      (should (not company-candidates)))))
+
 (ert-deftest company-should-complete-whitelist ()
   (with-temp-buffer
     (insert "ab")