Skip to content

Commit df34adf

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 705790f commit df34adf

File tree

1 file changed

+7
-0
lines changed

1 file changed

+7
-0
lines changed

Diff for: company-phpactor.el

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

34+
; this should have the same value as phpactor's completion.completor.class.limit value
35+
; by default, phpactor sets this to 100
36+
(defvar company-phpactor--completion-limit 100)
37+
(defvar company-phpactor--ignore-cache nil)
38+
3439
(defun company-phpactor--grab-symbol ()
3540
"If point is at the end of a symbol, return it.
3641
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."
5358
(defun company-phpactor--get-candidates ()
5459
"Build a list of candidates with text-properties extracted from phpactor's output."
5560
(let ((suggestions (company-phpactor--get-suggestions)) candidate)
61+
(setq company-phpactor--ignore-cache (= (length suggestions) company-phpactor--completion-limit))
5662
(mapcar
5763
(lambda (suggestion)
5864
(setq candidate (plist-get suggestion :name))
@@ -77,6 +83,7 @@ Here we create a temporary syntax table in order to add $ to symbols."
7783
(save-restriction
7884
(widen)
7985
(cl-case command
86+
(no-cache company-phpactor--ignore-cache)
8087
(post-completion (company-phpactor--post-completion arg))
8188
(annotation (company-phpactor--annotation arg))
8289
(interactive (company-begin-backend 'company-phpactor))

0 commit comments

Comments
 (0)