(with-temp-buffer
(company-mode)
(let (company-frontends
+ company-end-of-buffer-workaround
(company-backends
(list (lambda (command &optional arg)
(case command
(company-complete))
(should (string= "ab" (buffer-string)))
(delete-char -2)
- (insert "AB") ; hack, to keep it in one test
+ (insert "A") ; hack, to keep it in one test
(company-complete-selection)
(should (string= "abcd" (buffer-string))))))
(company-complete-selection)
(should (string= "ABcd" (buffer-string))))))
-(ert-deftest company-non-prefix-completion ()
- (with-temp-buffer
- (insert "tc")
- (company-mode)
- (let (company-frontends
- company-end-of-buffer-workaround
- (company-backends
- (list (lambda (command &optional arg)
- (case command
- (prefix (buffer-substring (point-min) (point)))
- (candidates '("tea-cup" "teal-color")))))))
- (let (this-command)
- (company-complete))
- (should (string= "tc" (buffer-string))))))
-
(ert-deftest company-non-prefix-completion ()
(with-temp-buffer
(insert "tc")
;; Save in cache:
(push (cons company-prefix company-candidates) company-candidates-cache)
;; Calculate common.
- (let ((completion-ignore-case (company-call-backend 'ignore-case))
- ;; We want to support non-prefix completion, so filtering is the
- ;; responsibility of each respective backend, not ours.
- ;; On the other hand, we don't want to replace non-prefix input in
- ;; `company-complete-common'.
- (common (try-completion company-prefix company-candidates)))
- (setq company-common (company--safe-candidate common))))
+ (let ((completion-ignore-case (company-call-backend 'ignore-case)))
+ ;; We want to support non-prefix completion, so filtering is the
+ ;; responsibility of each respective backend, not ours.
+ ;; On the other hand, we don't want to replace non-prefix input in
+ ;; `company-complete-common'.
+ (setq company-common (company--safe-candidate
+ (try-completion company-prefix company-candidates)))))
(defun company--safe-candidate (str)
(or (company-call-backend 'crop str)