@@ -1128,31 +1128,52 @@ let completionWithParser1 ~currentFile ~debug ~offset ~path ~posCursor
11281128 so the apply expression does not include the cursor *)
11291129 if setPipeResult ~lhs ~id: " " then setFound ()
11301130 (*
1131- A dot completion for a tagged templated application.
1131+ A dot completion for a tagged templated application with an expr hole .
11321132 Example:
11331133 sh`echo "meh"`.
1134- or
1135- sh`bar`.len
11361134 *)
11371135 | Pexp_apply
11381136 {
11391137 funct = {pexp_desc = Pexp_ident {txt = Lident " ." ; loc = _}};
11401138 args =
1141- [(_, ({pexp_desc = Pexp_apply _} as innerExpr)); (_, fieldExpr)];
1139+ [
1140+ (* sh`echo "meh"` *)
1141+ (_, ({pexp_desc = Pexp_apply _} as innerExpr));
1142+ (* recovery inserted node *)
1143+ (_, {pexp_desc = Pexp_extension ({txt = " rescript.exprhole" }, _)});
1144+ ];
1145+ }
1146+ when Res_parsetree_viewer. is_tagged_template_literal innerExpr ->
1147+ exprToContextPath innerExpr
1148+ |> Option. iter (fun cpath ->
1149+ setResult
1150+ (Cpath
1151+ (CPField
1152+ {
1153+ contextPath = cpath;
1154+ fieldName = " " ;
1155+ posOfDot;
1156+ exprLoc = expr.pexp_loc;
1157+ }));
1158+ setFound () )
1159+ (*
1160+ A dot completion for a tagged templated application with an ident.
1161+ Example:
1162+ sh`echo "meh"`.foo
1163+ *)
1164+ | Pexp_apply
1165+ {
1166+ funct = {pexp_desc = Pexp_ident {txt = Lident " ." ; loc = _}};
1167+ args =
1168+ [
1169+ (_, ({pexp_desc = Pexp_apply _} as innerExpr));
1170+ (_, {pexp_desc = Pexp_ident {txt = Lident fieldName}});
1171+ ];
11421172 }
11431173 when Res_parsetree_viewer. is_tagged_template_literal innerExpr
1144- && expr.pexp_loc |> Loc. hasPos ~pos: posBeforeCursor
1145- || CompletionExpressions. isExprHole fieldExpr ->
1174+ && expr.pexp_loc |> Loc. hasPos ~pos: posBeforeCursor ->
11461175 exprToContextPath innerExpr
11471176 |> Option. iter (fun cpath ->
1148- (* Determine the field name if present *)
1149- let fieldName =
1150- match fieldExpr.pexp_desc with
1151- | Pexp_ident {txt = Lident fieldName } -> fieldName
1152- (* This is likely to be an exprhole *)
1153- | _ -> " "
1154- in
1155-
11561177 setResult
11571178 (Cpath
11581179 (CPField
0 commit comments