@@ -428,7 +428,7 @@ let completionWithParser1 ~currentFile ~debug ~offset ~path ~posCursor ~text =
428
428
match ! lookingForPat with
429
429
| Some (Completable. Cpattern ({nested = None } as p )) ->
430
430
lookingForPat := Some (Cpattern {p with nested = Some [patternPat]})
431
- | Some (Completable. Cpattern ({nested = Some nested } as p )) ->
431
+ | Some (Cpattern ({nested = Some nested } as p )) ->
432
432
lookingForPat :=
433
433
Some (Cpattern {p with nested = Some (nested @ [patternPat])})
434
434
| _ -> ()
@@ -444,7 +444,7 @@ let completionWithParser1 ~currentFile ~debug ~offset ~path ~posCursor ~text =
444
444
setResult cpattern
445
445
| _ -> ()
446
446
in
447
-
447
+ (* Identifies expressions where we can do typed pattern or expr completion. *)
448
448
let typedCompletionExpr (exp : Parsetree.expression ) =
449
449
if
450
450
exp.pexp_loc
@@ -478,7 +478,7 @@ let completionWithParser1 ~currentFile ~debug ~offset ~path ~posCursor ~text =
478
478
| Some ctxPath -> setLookingForPat ctxPath)
479
479
| _ -> unsetLookingForPat
480
480
in
481
-
481
+ (* Tracks the path through a pattern for where the cursor is. *)
482
482
let typedCompletionPat (pat : Parsetree.pattern ) =
483
483
if
484
484
pat.ppat_loc
@@ -488,21 +488,21 @@ let completionWithParser1 ~currentFile ~debug ~offset ~path ~posCursor ~text =
488
488
match pat.ppat_desc with
489
489
| Ppat_var {txt} -> commitFoundPat ~prefix: txt ()
490
490
| Ppat_tuple patterns -> (
491
- let patCount = ref ( - 1 ) in
491
+ let patCount = ref None in
492
492
let patCountWithPatHole = ref None in
493
493
patterns
494
494
|> List. iteri (fun index p ->
495
495
match
496
496
p.Parsetree. ppat_loc
497
497
|> CursorPosition. classifyLoc ~pos: posBeforeCursor
498
498
with
499
- | HasCursor -> patCount := index
499
+ | HasCursor -> patCount := Some index
500
500
| EmptyLoc -> patCountWithPatHole := Some index
501
501
| _ -> () );
502
502
match (! patCount, ! patCountWithPatHole) with
503
- | patCount , _ when patCount > - 1 ->
503
+ | Some patCount , _ ->
504
504
appendNestedPat (Completable. PTupleItem {itemNum = patCount})
505
- | _ , Some patHoleCount ->
505
+ | None , Some patHoleCount ->
506
506
appendNestedPat (Completable. PTupleItem {itemNum = patHoleCount})
507
507
| _ -> () )
508
508
| Ppat_record ([] , _ ) ->
0 commit comments