Skip to content

Commit 0001537

Browse files
committed
dont complete for illegal file module names
1 parent 2c2552e commit 0001537

File tree

2 files changed

+9
-2
lines changed

2 files changed

+9
-2
lines changed

analysis/src/CompletionBackEnd.ml

+2-2
Original file line numberDiff line numberDiff line change
@@ -502,7 +502,7 @@ let getComplementaryCompletionsForTypedValue ~opens ~allFiles ~scope ~env prefix
502502
Utils.checkName name ~prefix ~exact
503503
&& not
504504
(* TODO complete the namespaced name too *)
505-
(String.contains name '-')
505+
(Utils.hasUnallowedChars name)
506506
then
507507
Some
508508
(Completion.create name ~env ~kind:(Completion.FileModule name))
@@ -528,7 +528,7 @@ let getCompletionsForPath ~debug ~package ~opens ~full ~pos ~exact ~scope
528528
Utils.checkName name ~prefix ~exact
529529
&& not
530530
(* TODO complete the namespaced name too *)
531-
(String.contains name '-')
531+
(Utils.hasUnallowedChars name)
532532
then
533533
Some
534534
(Completion.create name ~env ~kind:(Completion.FileModule name))

analysis/src/Utils.ml

+7
Original file line numberDiff line numberDiff line change
@@ -216,3 +216,10 @@ let rec lastElements list =
216216
let lowercaseFirstChar s =
217217
if String.length s = 0 then s
218218
else String.mapi (fun i c -> if i = 0 then Char.lowercase_ascii c else c) s
219+
220+
let hasUnallowedChars s =
221+
let regexp = Str.regexp "[^A-Za-z0-9]" in
222+
try
223+
ignore (Str.search_forward regexp s 0);
224+
true
225+
with Not_found -> false

0 commit comments

Comments
 (0)