Skip to content

Commit

Permalink
fixes a special case in switch expr completion
Browse files Browse the repository at this point in the history
  • Loading branch information
zth committed Jun 4, 2024
1 parent 169da71 commit 9f4bf94
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 0 deletions.
8 changes: 8 additions & 0 deletions analysis/src/CompletionFrontEnd.ml
Original file line number Diff line number Diff line change
Expand Up @@ -587,6 +587,14 @@ let completionWithParser1 ~currentFile ~debug ~offset ~path ~posCursor
if Debug.verbose () && debugTypedCompletionExpr then
print_endline "[typedCompletionExpr] No cases, rest";
()
| Pexp_match (expr, [{pc_lhs; pc_rhs}])
when locHasCursor expr.pexp_loc
&& CompletionExpressions.isExprHole pc_rhs
&& CompletionPatterns.isPatternHole pc_lhs ->
if Debug.verbose () && debugTypedCompletionExpr then
print_endline
"[typedCompletionExpr] No cases (expr and pat holes), rest";
()
| Pexp_match
( exp,
[
Expand Down
3 changes: 3 additions & 0 deletions analysis/tests/src/CompletionExpressions.res
Original file line number Diff line number Diff line change
Expand Up @@ -385,3 +385,6 @@ let {name} = hook({
includeName: true,
showMore: true,
})

// switch someTyp. { | }
// ^com
19 changes: 19 additions & 0 deletions analysis/tests/src/expected/CompletionExpressions.res.txt
Original file line number Diff line number Diff line change
Expand Up @@ -1459,3 +1459,22 @@ Path hook
"documentation": {"kind": "markdown", "value": "```rescript\noperator?: [#\"and\" | #or]\n```\n\n```rescript\ntype config = {includeName: bool, operator: option<[#\"and\" | #or]>, showMore: bool}\n```"}
}]

Complete src/CompletionExpressions.res 388:18
posCursor:[388:18] posNoWhite:[388:17] Found expr:[388:3->388:24]
posCursor:[388:18] posNoWhite:[388:17] Found expr:[388:10->388:18]
Pexp_field [388:10->388:17] _:[388:19->388:18]
Completable: Cpath Value[someTyp].""
Raw opens: 1 CompletionSupport.place holder
Package opens Pervasives.JsxModules.place holder
Resolved opens 2 pervasives CompletionSupport.res
ContextPath Value[someTyp].""
ContextPath Value[someTyp]
Path someTyp
[{
"label": "test",
"kind": 5,
"tags": [],
"detail": "bool",
"documentation": {"kind": "markdown", "value": "```rescript\ntest: bool\n```\n\n```rescript\ntype someTyp = {test: bool}\n```"}
}]

0 comments on commit 9f4bf94

Please sign in to comment.