Skip to content

Commit

Permalink
Improve operations
Browse files Browse the repository at this point in the history
  • Loading branch information
jcs090218 committed Jan 27, 2022
1 parent ca52f1b commit d281ec5
Showing 1 changed file with 9 additions and 10 deletions.
19 changes: 9 additions & 10 deletions company-fuzzy.el
Original file line number Diff line number Diff line change
Expand Up @@ -293,8 +293,8 @@ See function `string-prefix-p' for arguments PREFIX, STRING and IGNORE-CASE."

(defun company-fuzzy--backend-command (candidate command)
"Find the backend from the CANDIDATE then call the COMMAND."
(let ((backend (company-fuzzy--get-backend-by-candidate candidate)))
(if (or (string-empty-p candidate) (not backend)) nil
(unless (string-empty-p candidate)
(when-let ((backend (company-fuzzy--get-backend-by-candidate candidate)))
(company-fuzzy--call-backend backend command candidate))))

;;
Expand Down Expand Up @@ -490,12 +490,11 @@ does best describe the for this candidate."
;; for the best match.
;;
;; Example, if I have path `/path/to/dir'; then it shall return `dir'.
(let ((prefix (company-files 'prefix)))
(when prefix
(let* ((splitted (split-string prefix "/" t))
(len-splitted (length splitted))
(last (nth (1- len-splitted) splitted)))
last))))
(when-let* ((prefix (company-files 'prefix))
(splitted (split-string prefix "/" t))
(len-splitted (length splitted))
(last (nth (1- len-splitted) splitted)))
last))
(`company-yasnippet (thing-at-point 'symbol))
(t company-fuzzy--prefix)))

Expand Down Expand Up @@ -590,8 +589,8 @@ Insert .* between each char."

(defun company-fuzzy-all-candidates ()
"Return the list of all candidates."
(setq company-fuzzy--ht-backends-candidates (ht-create) ; Clean up.
company-fuzzy--is-trigger-prefix-p (company-fuzzy--trigger-prefix-p))
(ht-clear company-fuzzy--ht-backends-candidates) ; Clean up
(setq company-fuzzy--is-trigger-prefix-p (company-fuzzy--trigger-prefix-p))
(dolist (backend company-fuzzy--backends)
(if (memq backend company-fuzzy-passthrough-backends)
(company-fuzzy--candidates-from-passthrough-backend backend)
Expand Down

0 comments on commit d281ec5

Please sign in to comment.