Skip to content

Commit 344ac5c

Browse files
committed
handle regexps
1 parent a9b9545 commit 344ac5c

File tree

2 files changed

+5
-4
lines changed

2 files changed

+5
-4
lines changed

analysis/src/CompletionBackEnd.ml

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1451,9 +1451,10 @@ let rec completeTypedValue ?(typeArgContext : typeArgContext option) ~rawOpens
14511451
(* Special casing for things where we want extra things in the completions *)
14521452
let completionItems =
14531453
match path with
1454-
| Pdot (Pdot (Pident m, "Re", _), "t", _) when Ident.name m = "Js" ->
1454+
| Pdot (Pdot (Pident {name = "Js"}, "Re", _), "t", _)
1455+
| Pdot (Pident {name = "RegExp"}, "t", _) ->
14551456
(* regexps *)
1456-
create "%re()" ~insertText:"%re(\"/$0/g\")" ~includesSnippets:true
1457+
create "/<regexp>/g" ~insertText:"/$0/g" ~includesSnippets:true
14571458
~kind:(Label "Regular expression") ~env
14581459
:: completionItems
14591460
| _ -> completionItems

tests/analysis_tests/tests/src/expected/CompletionExpressions.res.txt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1259,12 +1259,12 @@ ContextPath CArgument Value[mkStuff]($0)
12591259
ContextPath Value[mkStuff]
12601260
Path mkStuff
12611261
[{
1262-
"label": "%re()",
1262+
"label": "/<regexp>/g",
12631263
"kind": 4,
12641264
"tags": [],
12651265
"detail": "Regular expression",
12661266
"documentation": null,
1267-
"insertText": "%re(\"/$0/g\")",
1267+
"insertText": "/$0/g",
12681268
"insertTextFormat": 2
12691269
}, {
12701270
"label": "Js.Re.fromString()",

0 commit comments

Comments
 (0)