Skip to content

Commit 0319a69

Browse files
committed
only add regular completions when there is a prefix to filter the results on
1 parent d3231cd commit 0319a69

File tree

2 files changed

+11
-1230
lines changed

2 files changed

+11
-1230
lines changed

analysis/src/CompletionBackEnd.ml

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1410,10 +1410,15 @@ let rec processCompletable ~debug ~full ~scope ~env ~pos ~forHover
14101410
fallbackOrEmpty ~items ())
14111411
| None -> fallbackOrEmpty ())
14121412
| Cexpression {contextPath; prefix; nested} -> (
1413-
(* Completions for local things like variables in scope, modules in the project, etc. *)
1413+
(* Completions for local things like variables in scope, modules in the
1414+
project, etc. We only add completions when there's a prefix of some sort
1415+
we can filter on, since we know we're in some sort of context, and
1416+
therefore don't want to overwhelm the user with completion items. *)
14141417
let regularCompletions =
1415-
prefix
1416-
|> getComplementaryCompletionsForTypedValue ~opens ~allFiles ~env ~scope
1418+
if prefix = "" then []
1419+
else
1420+
prefix
1421+
|> getComplementaryCompletionsForTypedValue ~opens ~allFiles ~env ~scope
14171422
in
14181423
match
14191424
contextPath
@@ -1537,8 +1542,8 @@ let rec processCompletable ~debug ~full ~scope ~env ~pos ~forHover
15371542
if Utils.startsWith elementName prefix then
15381543
let name = "<" ^ elementName ^ ">" in
15391544
Some
1540-
(Completion.create name ~kind:(Label name) ~detail:description ~env
1541-
~docstring:[description] ~insertText:elementName
1545+
(Completion.create name ~kind:(Label name) ~detail:description
1546+
~env ~docstring:[description] ~insertText:elementName
15421547
?deprecated:
15431548
(match deprecated with
15441549
| true -> Some "true"

0 commit comments

Comments
 (0)