Skip to content

Commit c3aa25d

Browse files
authored
Make lsp-completion-passthrough-try-completion more basic (#4602)
1 parent 0f156f2 commit c3aa25d

File tree

2 files changed

+13
-20
lines changed

2 files changed

+13
-20
lines changed

lsp-completion.el

Lines changed: 7 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -350,7 +350,8 @@ The MARKERS and PREFIX value will be attached to each candidate."
350350
(setq fuz-queries
351351
(plist-put fuz-queries start-point s))
352352
s)))
353-
(label-len (length label)))
353+
(label-len (length label))
354+
(case-fold-search completion-ignore-case))
354355
(when (string-match fuz-query label)
355356
(put-text-property 0 label-len 'match-data (match-data) label)
356357
(plist-put cand
@@ -701,7 +702,8 @@ Others: CANDIDATES"
701702
"Calculate fuzzy score for STR with query QUERY.
702703
The return is nil or in range of (0, inf)."
703704
(-when-let* ((md (cddr (or (get-text-property 0 'match-data str)
704-
(let ((re (lsp-completion--regex-fuz query)))
705+
(let ((re (lsp-completion--regex-fuz query))
706+
(case-fold-search completion-ignore-case))
705707
(when (string-match re str)
706708
(match-data))))))
707709
(start (pop md))
@@ -776,19 +778,9 @@ The return is nil or in range of (0, inf)."
776778
"Disable LSP completion support."
777779
(lsp-completion-mode -1))
778780

779-
(defun lsp-completion-passthrough-try-completion (string table pred point)
780-
(let* ((completion-ignore-case t)
781-
(try (completion-basic-try-completion string table pred point))
782-
(newstr (car try))
783-
(newpoint (cdr try))
784-
(beforepoint (and try (substring newstr 0 newpoint))))
785-
(if (and beforepoint
786-
(string-prefix-p
787-
beforepoint
788-
(try-completion "" table pred)
789-
t))
790-
try
791-
(cons string point))))
781+
(defun lsp-completion-passthrough-try-completion (string _table _pred point)
782+
"Passthrough try function, always return the passed STRING and POINT."
783+
(cons string point))
792784

793785
(defun lsp-completion-passthrough-all-completions (_string table pred _point)
794786
"Passthrough all completions from TABLE with PRED."

test/lsp-completion-test.el

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -36,11 +36,12 @@
3636

3737
(ert-deftest lsp-completion-test-fuz-score ()
3838
(cl-labels ((do-test (query cands expected)
39-
(should (equal
40-
(sort cands
41-
(lambda (l r) (> (lsp-completion--fuz-score query l)
42-
(lsp-completion--fuz-score query r))))
43-
expected))))
39+
(let ((completion-ignore-case t))
40+
(should (equal
41+
(sort cands
42+
(lambda (l r) (> (or (lsp-completion--fuz-score query l) 0)
43+
(or (lsp-completion--fuz-score query r) 0))))
44+
expected)))))
4445
(do-test "as"
4546
'("hashCode() : int"
4647
"asSubclass(Class<U> clazz) : Class<? extends U>")

0 commit comments

Comments
 (0)