diff --git a/company-phpactor.el b/company-phpactor.el index c140c7c..162b065 100644 --- a/company-phpactor.el +++ b/company-phpactor.el @@ -31,6 +31,11 @@ (require 'company) (require 'phpactor) +; this should have the same value as phpactor's completion.completor.class.limit value +; by default, phpactor sets this to 100 +(defvar company-phpactor--completion-limit 100) +(defvar company-phpactor--ignore-cache nil) + (defun company-phpactor--grab-symbol () "If point is at the end of a symbol, return it. Otherwise, if point is not inside a symbol, return an empty string. @@ -53,6 +58,7 @@ Here we create a temporary syntax table in order to add $ to symbols." (defun company-phpactor--get-candidates () "Build a list of candidates with text-properties extracted from phpactor's output." (let ((suggestions (company-phpactor--get-suggestions)) candidate) + (setq company-phpactor--ignore-cache (= (length suggestions) company-phpactor--completion-limit)) (mapcar (lambda (suggestion) (setq candidate (plist-get suggestion :name)) @@ -77,6 +83,7 @@ Here we create a temporary syntax table in order to add $ to symbols." (save-restriction (widen) (cl-case command + (no-cache company-phpactor--ignore-cache) (post-completion (company-phpactor--post-completion arg)) (annotation (company-phpactor--annotation arg)) (interactive (company-begin-backend 'company-phpactor))