@@ -802,7 +802,7 @@ let completionWithParser1 ~currentFile ~debug ~offset ~path ~posCursor ~text =
802802 (* Case foo-> when the parser adds a ghost expression to the rhs
803803 so the apply expression does not include the cursor *)
804804 if setPipeResult ~lhs ~id: " " then setFound ()
805- | _ ->
805+ | _ -> (
806806 if expr.pexp_loc |> Loc. hasPos ~pos: posNoWhite && ! result = None then (
807807 setFound () ;
808808 match expr.pexp_desc with
@@ -1010,38 +1010,37 @@ let completionWithParser1 ~currentFile ~debug ~offset ~path ~posCursor ~text =
10101010 | None -> () )
10111011 | Pexp_fun (lbl , defaultExpOpt , pat , e ) ->
10121012 let oldScope = ! scope in
1013- let oldCtxPath = ! currentCtxPath in
10141013 (match (! processingFun, ! currentCtxPath) with
10151014 | None , Some ctxPath -> processingFun := Some (ctxPath, 0 )
10161015 | _ -> () );
1017- (match ! processingFun with
1018- | None -> ()
1019- | Some (ctxPath , currentUnlabelledCount ) -> (
1020- setCurrentCtxPath
1021- (CArgument
1022- {
1023- functionContextPath = ctxPath;
1024- argumentLabel =
1025- (match lbl with
1026- | Nolabel ->
1027- Unlabelled {argumentPosition = currentUnlabelledCount}
1028- | Optional name -> Optional name
1029- | Labelled name -> Labelled name);
1030- });
1031- processingFun :=
1032- match lbl with
1033- | Nolabel -> Some (ctxPath, currentUnlabelledCount + 1 )
1034- | _ -> Some (ctxPath, currentUnlabelledCount)));
1016+ let argContextPath =
1017+ match ! processingFun with
1018+ | None -> None
1019+ | Some (ctxPath , currentUnlabelledCount ) ->
1020+ (processingFun :=
1021+ match lbl with
1022+ | Nolabel -> Some (ctxPath, currentUnlabelledCount + 1 )
1023+ | _ -> Some (ctxPath, currentUnlabelledCount));
1024+ Some
1025+ (Completable. CArgument
1026+ {
1027+ functionContextPath = ctxPath;
1028+ argumentLabel =
1029+ (match lbl with
1030+ | Nolabel ->
1031+ Unlabelled {argumentPosition = currentUnlabelledCount}
1032+ | Optional name -> Optional name
1033+ | Labelled name -> Labelled name);
1034+ })
1035+ in
10351036 (match defaultExpOpt with
10361037 | None -> ()
10371038 | Some defaultExp -> iterator.expr iterator defaultExp);
1038- let currentContextPath = ! currentCtxPath in
1039- completePattern ?contextPath:currentContextPath pat;
1040- scopePattern ?contextPath:currentContextPath pat;
1039+ completePattern ?contextPath:argContextPath pat;
1040+ scopePattern ?contextPath:argContextPath pat;
10411041 iterator.pat iterator pat;
10421042 iterator.expr iterator e;
10431043 scope := oldScope;
1044- resetCurrentCtxPath oldCtxPath;
10451044 processed := true
10461045 | Pexp_let (recFlag , bindings , e ) ->
10471046 let oldScope = ! scope in
@@ -1068,7 +1067,10 @@ let completionWithParser1 ~currentFile ~debug ~offset ~path ~posCursor ~text =
10681067 processed := true
10691068 | _ -> () );
10701069 if not ! processed then Ast_iterator. default_iterator.expr iterator expr;
1071- inJsxContext := oldInJsxContext
1070+ inJsxContext := oldInJsxContext;
1071+ match expr.pexp_desc with
1072+ | Pexp_fun _ -> ()
1073+ | _ -> processingFun := None )
10721074 in
10731075 let typ (iterator : Ast_iterator.iterator ) (core_type : Parsetree.core_type ) =
10741076 if core_type.ptyp_loc |> Loc. hasPos ~pos: posNoWhite then (
0 commit comments