@@ -268,6 +268,7 @@ let completionWithParser1 ~currentFile ~debug ~offset ~path ~posCursor ~text =
268
268
in
269
269
270
270
let currentCtxPath = ref None in
271
+ let processingFun = ref None in
271
272
let setCurrentCtxPath ctxPath =
272
273
if ! Cfg. debugFollowCtxPath then
273
274
Printf. printf " setting current ctxPath: %s\n "
@@ -1010,25 +1011,27 @@ let completionWithParser1 ~currentFile ~debug ~offset ~path ~posCursor ~text =
1010
1011
| Pexp_fun (lbl , defaultExpOpt , pat , e ) ->
1011
1012
let oldScope = ! scope in
1012
1013
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
1020
1018
| None -> ()
1021
- | Some ctxPath ->
1019
+ | Some ( ctxPath , currentUnlabelledCount ) -> (
1022
1020
setCurrentCtxPath
1023
1021
(CArgument
1024
1022
{
1025
1023
functionContextPath = ctxPath;
1026
1024
argumentLabel =
1027
1025
(match lbl with
1028
- | Nolabel -> Unlabelled {argumentPosition = 0 }
1026
+ | Nolabel ->
1027
+ Unlabelled {argumentPosition = currentUnlabelledCount}
1029
1028
| Optional name -> Optional name
1030
1029
| Labelled name -> Labelled name);
1031
- }));
1030
+ });
1031
+ processingFun :=
1032
+ match lbl with
1033
+ | Nolabel -> Some (ctxPath, currentUnlabelledCount + 1 )
1034
+ | _ -> Some (ctxPath, currentUnlabelledCount)));
1032
1035
(match defaultExpOpt with
1033
1036
| None -> ()
1034
1037
| Some defaultExp -> iterator.expr iterator defaultExp);
0 commit comments