@@ -188,7 +188,7 @@ module CompletionContext = struct
188
188
ctxPath = [] ;
189
189
}
190
190
191
- let withResetCtx completionContext =
191
+ let resetCtx completionContext =
192
192
{completionContext with currentlyExpecting = Unit ; ctxPath = [] }
193
193
194
194
let withScope scope completionContext = {completionContext with scope}
@@ -597,7 +597,7 @@ and completeValueBinding ~(completionContext : CompletionContext.t)
597
597
in
598
598
(* Always reset the context when completing value bindings,
599
599
since they create their own context. *)
600
- let completionContext = CompletionContext. withResetCtx completionContext in
600
+ let completionContext = CompletionContext. resetCtx completionContext in
601
601
if locHasPos vb.pvb_pat.ppat_loc then
602
602
(* Completing the pattern of the binding. `let {<com>} = someRecordVariable`.
603
603
Ensure the context carries the root type of `someRecordVariable`. *)
@@ -831,7 +831,7 @@ and completeExpr ~completionContext (expr : Parsetree.expression) :
831
831
if locHasPos condition.pexp_loc then
832
832
(* TODO: I guess we could set looking for to "bool" here, since it's the if condition *)
833
833
completeExpr
834
- ~completion Context:(CompletionContext. withResetCtx completionContext)
834
+ ~completion Context:(CompletionContext. resetCtx completionContext)
835
835
condition
836
836
else if locHasPos then_.pexp_loc then completeExpr ~completion Context then_
837
837
else
@@ -857,7 +857,7 @@ and completeExpr ~completionContext (expr : Parsetree.expression) :
857
857
| Pexp_sequence (evalExpr , nextExpr ) ->
858
858
if locHasPos evalExpr.pexp_loc then
859
859
completeExpr
860
- ~completion Context:(CompletionContext. withResetCtx completionContext)
860
+ ~completion Context:(CompletionContext. resetCtx completionContext)
861
861
evalExpr
862
862
else if locHasPos nextExpr.pexp_loc then
863
863
completeExpr ~completion Context nextExpr
@@ -875,7 +875,7 @@ and completeExpr ~completionContext (expr : Parsetree.expression) :
875
875
match completePipe lhs ~id: " " with
876
876
| None -> None
877
877
| Some cpipe ->
878
- completionContext |> CompletionContext. withResetCtx
878
+ completionContext |> CompletionContext. resetCtx
879
879
|> CompletionResult. ctxPath cpipe)
880
880
| Pexp_apply
881
881
( {pexp_desc = Pexp_ident {txt = Lident (" |." | " |.u" )}},
@@ -888,7 +888,7 @@ and completeExpr ~completionContext (expr : Parsetree.expression) :
888
888
match completePipe lhs ~id with
889
889
| None -> None
890
890
| Some cpipe ->
891
- completionContext |> CompletionContext. withResetCtx
891
+ completionContext |> CompletionContext. resetCtx
892
892
|> CompletionResult. ctxPath cpipe)
893
893
| Pexp_apply
894
894
( {pexp_desc = Pexp_ident {txt = Lident (" |." | " |.u" ); loc = opLoc}},
@@ -897,17 +897,22 @@ and completeExpr ~completionContext (expr : Parsetree.expression) :
897
897
match completePipe lhs ~id: " " with
898
898
| None -> None
899
899
| Some cpipe ->
900
- completionContext |> CompletionContext. withResetCtx
900
+ completionContext |> CompletionContext. resetCtx
901
901
|> CompletionResult. ctxPath cpipe)
902
- | Pexp_apply ({pexp_desc = Pexp_ident {txt = Lident (" |." | " |.u" )}}, [_; _])
903
- ->
904
- (* Ignore any other pipe. *)
905
- None
902
+ | Pexp_apply
903
+ ( {pexp_desc = Pexp_ident {txt = Lident (" |." | " |.u" )}},
904
+ [(_, lhs); (_, rhs)] ) ->
905
+ (* Descend into pipe parts if none of the special cases above works
906
+ but the cursor is somewhere here. *)
907
+ let completionContext = completionContext |> CompletionContext. resetCtx in
908
+ if locHasPos lhs.pexp_loc then completeExpr ~completion Context lhs
909
+ else if locHasPos rhs.pexp_loc then completeExpr ~completion Context rhs
910
+ else None
906
911
| Pexp_apply (fnExpr , args ) -> (
907
912
if locHasPos fnExpr.pexp_loc then
908
913
(* someFn<com>(). Cursor in the function expression itself. *)
909
914
completeExpr
910
- ~completion Context:(CompletionContext. withResetCtx completionContext)
915
+ ~completion Context:(CompletionContext. resetCtx completionContext)
911
916
fnExpr
912
917
else
913
918
(* Check if the args has the cursor. *)
@@ -925,7 +930,7 @@ and completeExpr ~completionContext (expr : Parsetree.expression) :
925
930
(* TODO: Complete labelled argument names, pipes *)
926
931
let makeCompletionContextWithArgumentLabel argumentLabel
927
932
~functionContextPath =
928
- completionContext |> CompletionContext. withResetCtx
933
+ completionContext |> CompletionContext. resetCtx
929
934
|> CompletionContext. currentlyExpectingOrReset
930
935
(Some
931
936
(Type (CFunctionArgument {functionContextPath; argumentLabel})))
0 commit comments