@@ -268,6 +268,7 @@ let completionWithParser1 ~currentFile ~debug ~offset ~path ~posCursor ~text =
268268 in
269269
270270 let currentCtxPath = ref None in
271+ let processingFun = ref None in
271272 let setCurrentCtxPath ctxPath =
272273 if ! Cfg. debugFollowCtxPath then
273274 Printf. printf " setting current ctxPath: %s\n "
@@ -1010,25 +1011,27 @@ let completionWithParser1 ~currentFile ~debug ~offset ~path ~posCursor ~text =
10101011 | Pexp_fun (lbl , defaultExpOpt , pat , e ) ->
10111012 let oldScope = ! scope in
10121013 let oldCtxPath = ! currentCtxPath in
1013- (* TODO: Haven't figured out how to count unlabelled args here yet... *)
1014- (* TODO: This is broken. I'm trying to set the CArgument context path
1015- below here continuously for each argument as I traverse the expr
1016- for the arg, but I end up piling them on each other. So what should
1017- be Carg $0, then Carg $1, then Carg $3... is now (faulty) Carg $0,
1018- then Carg Carg $0 $1, then Carg Carg Carg $0 $1 $2, and so on. *)
1019- (match ! currentCtxPath with
1014+ (match (! processingFun, ! currentCtxPath) with
1015+ | None , Some ctxPath -> processingFun := Some (ctxPath, 0 )
1016+ | _ -> () );
1017+ (match ! processingFun with
10201018 | None -> ()
1021- | Some ctxPath ->
1019+ | Some ( ctxPath , currentUnlabelledCount ) -> (
10221020 setCurrentCtxPath
10231021 (CArgument
10241022 {
10251023 functionContextPath = ctxPath;
10261024 argumentLabel =
10271025 (match lbl with
1028- | Nolabel -> Unlabelled {argumentPosition = 0 }
1026+ | Nolabel ->
1027+ Unlabelled {argumentPosition = currentUnlabelledCount}
10291028 | Optional name -> Optional name
10301029 | Labelled name -> Labelled name);
1031- }));
1030+ });
1031+ processingFun :=
1032+ match lbl with
1033+ | Nolabel -> Some (ctxPath, currentUnlabelledCount + 1 )
1034+ | _ -> Some (ctxPath, currentUnlabelledCount)));
10321035 (match defaultExpOpt with
10331036 | None -> ()
10341037 | Some defaultExp -> iterator.expr iterator defaultExp);
0 commit comments