@@ -420,16 +420,14 @@ let completionWithParser ~currentFile ~debug ~offset ~path ~posCursor text =
420
420
if expr.pexp_loc |> Loc. hasPos ~pos: posNoWhite && ! result = None then (
421
421
setFound () ;
422
422
match expr.pexp_desc with
423
- | Pexp_match (switchExpr, [{pc_lhs = lhsPat}])
423
+ ( * | Pexp_match (switchExpr , [{pc_lhs = lhsPat } ])
424
424
when CompletionPatterns. isPatternHole lhsPat
425
425
&& locHasCursor switchExpr .pexp_loc = false ->
426
- setResult (Cpattern {kind = Empty ; typeLoc = switchExpr.pexp_loc})
426
+ setResult (Cpattern {kind = Empty ; typeLoc = switchExpr .pexp_loc } ) * )
427
427
| Pexp_match (switchExpr , cases ) ->
428
428
let oldTypeLoc = ! currentTypeLoc in
429
429
currentTypeLoc := Some switchExpr.pexp_loc;
430
- cases
431
- |> List. iter (fun case ->
432
- Ast_iterator. default_iterator.case iterator case);
430
+ cases |> List. iter (fun case -> iterator.case iterator case);
433
431
currentTypeLoc := oldTypeLoc;
434
432
processed := true
435
433
| Pexp_extension ({txt = "obj" } , PStr [str_item ]) ->
@@ -615,6 +613,10 @@ let completionWithParser ~currentFile ~debug ~offset ~path ~posCursor text =
615
613
| _ -> () );
616
614
if not ! processed then Ast_iterator. default_iterator.expr iterator expr
617
615
in
616
+ let case (_iterator : Ast_iterator.iterator ) (case : Parsetree.case ) =
617
+ if case.pc_loc |> Loc. hasPos ~pos: posCursor then
618
+ setResult (Ccase case.pc_loc)
619
+ in
618
620
let typ (iterator : Ast_iterator.iterator ) (core_type : Parsetree.core_type ) =
619
621
if core_type.ptyp_loc |> Loc. hasPos ~pos: posNoWhite then (
620
622
found := true ;
@@ -781,6 +783,7 @@ let completionWithParser ~currentFile ~debug ~offset ~path ~posCursor text =
781
783
Ast_iterator. default_iterator with
782
784
attribute;
783
785
expr;
786
+ case;
784
787
location;
785
788
module_expr;
786
789
module_type;
@@ -800,7 +803,8 @@ let completionWithParser ~currentFile ~debug ~offset ~path ~posCursor text =
800
803
Res_driver. parsing_engine.parse_implementation ~for_printer: false
801
804
in
802
805
let {Res_driver. parsetree = str} = parser ~filename: currentFile in
803
- iterator.structure iterator str |> ignore;
806
+ let tree = Res_recovery. map str in
807
+ iterator.structure iterator tree |> ignore;
804
808
if blankAfterCursor = Some ' ' || blankAfterCursor = Some '\n' then
805
809
scope := ! lastScopeBeforeCursor
806
810
(* TODO(revamp) Complete any value *)
0 commit comments