Skip to content

Commit

Permalink
If table is a function, only passthrough if its result is non-nil (#4684
Browse files Browse the repository at this point in the history
)

* If table is a function, only passthrough if its result is non-nil

* Let non-empty hash tables pass through as well
  • Loading branch information
wyuenho authored Jan 16, 2025
1 parent 0252be2 commit 2e5f23a
Showing 1 changed file with 13 additions and 3 deletions.
16 changes: 13 additions & 3 deletions lsp-completion.el
Original file line number Diff line number Diff line change
Expand Up @@ -850,9 +850,19 @@ The return is nil or in range of (0, inf)."
"Disable LSP completion support."
(lsp-completion-mode -1))

(defun lsp-completion-passthrough-try-completion (string table _pred point)
"Passthrough try function, always return the passed STRING and POINT."
(when table
(defun lsp-completion-passthrough-try-completion (string table pred point)
"Passthrough try function.
If TABLE is a function, it is called with STRING, PRED and nil to get
the candidates, otherwise it is treated as the candidates.
If the candidates is non-empty, return the passed STRING and POINT."
(when (pcase table
((pred functionp)
(funcall table string pred nil))
((pred hash-table-p)
(not (hash-table-empty-p table)))
(_ table))
(cons string point)))

(defun lsp-completion-passthrough-all-completions (_string table pred _point)
Expand Down

0 comments on commit 2e5f23a

Please sign in to comment.