@@ -556,9 +556,10 @@ let isCapitalized name =
556556 match c with 'A' .. 'Z' -> true | _ -> false
557557
558558type 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 *)
560560 | 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 *)
562563
563564let determineCompletion dotpath =
564565 let rec loop dotpath =
@@ -574,13 +575,22 @@ let determineCompletion dotpath =
574575 | Path path -> Path (one :: path)
575576 | RecordAccess (valuePath , middleFields , lastField ) ->
576577 RecordAccess (one :: valuePath, middleFields, lastField)
577- | AbsAttribute _ as x -> x
578+ | QualifiedRecordAccess _ as completion ->
579+ (* A. _.B.field -> _.B.field *)
580+ completion
578581 else
579582 match loop rest with
580- | Path path -> AbsAttribute path
583+ | Path path ->
584+ (* x. B.field -> _.B.field *)
585+ QualifiedRecordAccess path
581586 | RecordAccess ([name ], middleFields , lastField ) ->
582587 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)
584594 in
585595 loop dotpath
586596
@@ -864,7 +874,7 @@ let getItems ~full ~rawOpens ~allFiles ~pos ~dotpath =
864874 }
865875 else None ))))
866876 | None -> [] )
867- | AbsAttribute path -> (
877+ | QualifiedRecordAccess path -> (
868878 match getEnvWithOpens ~pos ~env ~package ~opens path with
869879 | None -> []
870880 | Some (env , suffix ) ->
0 commit comments