@@ -802,7 +802,7 @@ let completionWithParser1 ~currentFile ~debug ~offset ~path ~posCursor ~text =
802
802
(* Case foo-> when the parser adds a ghost expression to the rhs
803
803
so the apply expression does not include the cursor *)
804
804
if setPipeResult ~lhs ~id: " " then setFound ()
805
- | _ ->
805
+ | _ -> (
806
806
if expr.pexp_loc |> Loc. hasPos ~pos: posNoWhite && ! result = None then (
807
807
setFound () ;
808
808
match expr.pexp_desc with
@@ -1010,38 +1010,37 @@ let completionWithParser1 ~currentFile ~debug ~offset ~path ~posCursor ~text =
1010
1010
| None -> () )
1011
1011
| Pexp_fun (lbl , defaultExpOpt , pat , e ) ->
1012
1012
let oldScope = ! scope in
1013
- let oldCtxPath = ! currentCtxPath in
1014
1013
(match (! processingFun, ! currentCtxPath) with
1015
1014
| None , Some ctxPath -> processingFun := Some (ctxPath, 0 )
1016
1015
| _ -> () );
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
1035
1036
(match defaultExpOpt with
1036
1037
| None -> ()
1037
1038
| 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;
1041
1041
iterator.pat iterator pat;
1042
1042
iterator.expr iterator e;
1043
1043
scope := oldScope;
1044
- resetCurrentCtxPath oldCtxPath;
1045
1044
processed := true
1046
1045
| Pexp_let (recFlag , bindings , e ) ->
1047
1046
let oldScope = ! scope in
@@ -1068,7 +1067,10 @@ let completionWithParser1 ~currentFile ~debug ~offset ~path ~posCursor ~text =
1068
1067
processed := true
1069
1068
| _ -> () );
1070
1069
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 )
1072
1074
in
1073
1075
let typ (iterator : Ast_iterator.iterator ) (core_type : Parsetree.core_type ) =
1074
1076
if core_type.ptyp_loc |> Loc. hasPos ~pos: posNoWhite then (
0 commit comments