Skip to content

Commit a8f65f9

Browse files
committed
refactor
1 parent a33c4f0 commit a8f65f9

File tree

1 file changed

+8
-6
lines changed

1 file changed

+8
-6
lines changed

analysis/src/CompletionFrontEnd.ml

+8-6
Original file line numberDiff line numberDiff line change
@@ -711,26 +711,28 @@ let completionWithParser1 ~currentFile ~debug ~offset ~path ~posCursor ~text =
711711
match exp |> exprToContextPath with
712712
| None -> ()
713713
| Some ctxPath -> (
714-
let caseWithCursor =
714+
let hasCaseWithCursor =
715715
cases
716716
|> List.find_opt (fun case ->
717717
case.Parsetree.pc_lhs.ppat_loc
718718
|> CursorPosition.classifyLoc ~pos:posBeforeCursor
719719
= HasCursor)
720+
|> Option.is_some
720721
in
721-
let caseWithPatHole =
722+
let hasCaseWithPatHole =
722723
cases
723724
|> List.find_opt (fun case -> isPatternHole case.Parsetree.pc_lhs)
725+
|> Option.is_some
724726
in
725-
match (caseWithPatHole, caseWithCursor) with
726-
| _, Some _ ->
727+
match (hasCaseWithPatHole, hasCaseWithCursor) with
728+
| _, true ->
727729
(* Always continue if there's a case with the cursor *)
728730
setLookingForPat ctxPath
729-
| Some _, None ->
731+
| true, false ->
730732
(* If there's no case with the cursor, but a broken parser case, complete for the top level. *)
731733
setResult
732734
(Completable.Cpattern {typ = ctxPath; nested = []; prefix = ""})
733-
| None, None -> ()))
735+
| false, false -> ()))
734736
| _ -> unsetLookingForPat ()
735737
in
736738

0 commit comments

Comments
 (0)