Skip to content

Commit 4dc4e7a

Browse files
committed
Handle case "x.M. ".
1 parent 6b9d1c1 commit 4dc4e7a

File tree

3 files changed

+21
-3
lines changed

3 files changed

+21
-3
lines changed

analysis/src/Completion.ml

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -518,7 +518,10 @@ let completionWithParser ~debug ~path ~posCursor ~currentFile ~text =
518518
let contextPath =
519519
Completable.CPField
520520
( CPId (Utils.flattenLongIdent id, Module),
521-
if name = "_" then "" else name )
521+
if blankAfterCursor = Some '.' then
522+
(* x.M. field ---> M. *) ""
523+
else if name = "_" then ""
524+
else name )
522525
in
523526
setResult (Cpath contextPath)
524527
| Lapply _ -> ()

analysis/tests/src/RecordCompletion.res

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,3 +19,6 @@ module R = {
1919
let n = {R.name: ""}
2020
// n.R.
2121
// ^com
22+
23+
// n.R. xx
24+
// ^com

analysis/tests/src/expected/RecordCompletion.res.txt

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,8 +33,20 @@ Completable: Cpath Value[t2].n2.n->m
3333
}]
3434

3535
Complete tests/src/RecordCompletion.res 19:7
36-
posCursor:[19:7] posNoWhite:[19:6] Found expr:[19:3->22:0]
37-
Pexp_field [19:3->19:4] R.:[19:5->22:0]
36+
posCursor:[19:7] posNoWhite:[19:6] Found expr:[19:3->25:0]
37+
Pexp_field [19:3->19:4] R.:[19:5->25:0]
38+
Completable: Cpath Module[R].""
39+
[{
40+
"label": "name",
41+
"kind": 5,
42+
"tags": [],
43+
"detail": "name: string\n\ntype t = {name: string}",
44+
"documentation": null
45+
}]
46+
47+
Complete tests/src/RecordCompletion.res 22:7
48+
posCursor:[22:7] posNoWhite:[22:6] Found expr:[22:3->22:10]
49+
Pexp_field [22:3->22:4] R.xx:[22:5->22:10]
3850
Completable: Cpath Module[R].""
3951
[{
4052
"label": "name",

0 commit comments

Comments
 (0)