branch: master commit 829b40f1a4bad7e8ab3f89f0ceb84d5edc0b4823 Author: Dmitry Gutov <dgu...@yandex.ru> Commit: Dmitry Gutov <dgu...@yandex.ru>
company--continue-failed: Don't burp on `stop' #273 --- company.el | 1 + test/core-tests.el | 24 ++++++++++++++++++++++-- 2 files changed, 23 insertions(+), 2 deletions(-) diff --git a/company.el b/company.el index c53d7ae..e6bebbf 100644 --- a/company.el +++ b/company.el @@ -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, diff --git a/test/core-tests.el b/test/core-tests.el index 0ff691e..90ce69c 100644 --- a/test/core-tests.el +++ b/test/core-tests.el @@ -207,12 +207,12 @@ (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 @@ -230,6 +230,26 @@ (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")