@@ -556,9 +556,10 @@ let isCapitalized name =
556
556
match c with 'A' .. 'Z' -> true | _ -> false
557
557
558
558
type completion =
559
- | AbsAttribute of string list (* e.g. _somepath_ .A.B.field *)
559
+ | QualifiedRecordAccess of string list (* e.g. _ .A.B.field where _ indicates a path ending in a lowercase id *)
560
560
| RecordAccess of string list * string list * string (* e.g. A.B.var .f1.f2 .f3 *)
561
- | Path of string list (* e.g. A.B.var or A.B *)
561
+ | Path of string list
562
+ (* e.g. A.B.var or A.B *)
562
563
563
564
let determineCompletion dotpath =
564
565
let rec loop dotpath =
@@ -574,13 +575,22 @@ let determineCompletion dotpath =
574
575
| Path path -> Path (one :: path)
575
576
| RecordAccess (valuePath , middleFields , lastField ) ->
576
577
RecordAccess (one :: valuePath, middleFields, lastField)
577
- | AbsAttribute _ as x -> x
578
+ | QualifiedRecordAccess _ as completion ->
579
+ (* A. _.B.field -> _.B.field *)
580
+ completion
578
581
else
579
582
match loop rest with
580
- | Path path -> AbsAttribute path
583
+ | Path path ->
584
+ (* x. B.field -> _.B.field *)
585
+ QualifiedRecordAccess path
581
586
| RecordAccess ([name ], middleFields , lastField ) ->
582
587
RecordAccess ([one], name :: middleFields, lastField)
583
- | x -> x)
588
+ | RecordAccess (valuePath , middleFields , lastField ) ->
589
+ (* x.A.B.v.f1.f2.f3 --> .A.B.v.f1.f2.f3 *)
590
+ QualifiedRecordAccess (valuePath @ middleFields @ [lastField])
591
+ | QualifiedRecordAccess _ as completion ->
592
+ (* x. _.A.f -> _.A.f *)
593
+ completion)
584
594
in
585
595
loop dotpath
586
596
@@ -864,7 +874,7 @@ let getItems ~full ~rawOpens ~allFiles ~pos ~dotpath =
864
874
}
865
875
else None ))))
866
876
| None -> [] )
867
- | AbsAttribute path -> (
877
+ | QualifiedRecordAccess path -> (
868
878
match getEnvWithOpens ~pos ~env ~package ~opens path with
869
879
| None -> []
870
880
| Some (env , suffix ) ->
0 commit comments