Skip to content

Commit 9e12ba5

Browse files
committed
toggle completion caching whether number of candidates reaches limit
if the number of suggested candidates reaches the limit, the desired candidate might be missing. If that occurs, caching should not be used when typing more characters of the completed string, as phpactor will be invoked with a longer prefix, and have more chances to return the desired candidate.
1 parent eda8b34 commit 9e12ba5

File tree

1 file changed

+7
-0
lines changed

1 file changed

+7
-0
lines changed

company-phpactor.el

+7
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,11 @@
3232
(require 'company)
3333
(require 'phpactor)
3434

35+
; this should have the same value as phpactor's completion.completor.class.limit value
36+
; by default, phpactor sets this to 100
37+
(defvar company-phpactor--completion-limit 100)
38+
(defvar company-phpactor--ignore-cache nil)
39+
3540
(defun company-phpactor--grab-symbol ()
3641
"If point is at the end of a symbol, return it.
3742
Otherwise, if point is not inside a symbol, return an empty string.
@@ -54,6 +59,7 @@ Here we create a temporary syntax table in order to add $ to symbols."
5459
(defun company-phpactor--get-candidates ()
5560
"Build a list of candidates with text-properties extracted from phpactor's output."
5661
(let ((suggestions (company-phpactor--get-suggestions)) candidate)
62+
(setq company-phpactor--ignore-cache (= (length suggestions) company-phpactor--completion-limit))
5763
(mapcar
5864
(lambda (suggestion)
5965
(setq candidate (plist-get suggestion :name))
@@ -80,6 +86,7 @@ Here we create a temporary syntax table in order to add $ to symbols."
8086
(save-restriction
8187
(widen)
8288
(cl-case command
89+
(no-cache company-phpactor--ignore-cache)
8390
(post-completion (company-phpactor--post-completion arg))
8491
(annotation (company-phpactor--annotation arg))
8592
(interactive (company-begin-backend 'company-phpactor))

0 commit comments

Comments
 (0)