branch: master commit ff9bafc2628ea0f48c5d682d48985d4b29eceda1 Author: Dmitry Gutov <dgu...@yandex.ru> Commit: Dmitry Gutov <dgu...@yandex.ru>
Don't idle-begin when company-candidates is non-nil That should prevent bugs like ensime/ensime-server#754 in the future. --- company.el | 20 +++++++++++--------- 1 files changed, 11 insertions(+), 9 deletions(-) diff --git a/company.el b/company.el index e2ba78d..c53d7ae 100644 --- a/company.el +++ b/company.el @@ -1136,7 +1136,8 @@ can retrieve meta-data for them." (cdr c) (lambda (candidates) (if (not (and candidates (eq res 'done))) - ;; Fetcher called us back right away. + ;; There's no completions to display, + ;; or the fetcher called us back right away. (setq res candidates) (setq company-backend backend company-candidates-cache @@ -1287,15 +1288,14 @@ from the rest of the back-ends in the group, if any, will be left at the end." (not company-candidates) (let ((company-idle-delay 'now)) (condition-case-unless-debug err - (company--perform) + (progn + (company--perform) + ;; Return non-nil if active. + company-candidates) (error (message "Company: An error occurred in auto-begin") (message "%s" (error-message-string err)) (company-cancel)) - (quit (company-cancel))))) - (unless company-candidates - (setq company-backend nil)) - ;; Return non-nil if active. - company-candidates) + (quit (company-cancel)))))) (defun company-manual-begin () (interactive) @@ -1303,7 +1303,8 @@ from the rest of the back-ends in the group, if any, will be left at the end." (setq company--manual-action t) (unwind-protect (let ((company-minimum-prefix-length 0)) - (company-auto-begin)) + (or company-candidates + (company-auto-begin))) (unless company-candidates (setq company--manual-action nil)))) @@ -1454,7 +1455,8 @@ from the rest of the back-ends in the group, if any, will be left at the end." (defun company--perform () (or (and company-candidates (company--continue)) (and (company--should-complete) (company--begin-new))) - (when company-candidates + (if (not company-candidates) + (setq company-backend nil) (setq company-point (point) company--point-max (point-max)) (company-ensure-emulation-alist)