Skip to content

Commit 94e955e

Browse files
committed
refactor
1 parent 54a91bb commit 94e955e

File tree

1 file changed

+8
-6
lines changed

1 file changed

+8
-6
lines changed

analysis/src/CompletionFrontEnd.ml

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -718,26 +718,28 @@ let completionWithParser1 ~currentFile ~debug ~offset ~path ~posCursor ~text =
718718
match exp |> exprToContextPath with
719719
| None -> ()
720720
| Some ctxPath -> (
721-
let caseWithCursor =
721+
let hasCaseWithCursor =
722722
cases
723723
|> List.find_opt (fun case ->
724724
case.Parsetree.pc_lhs.ppat_loc
725725
|> CursorPosition.classifyLoc ~pos:posBeforeCursor
726726
= HasCursor)
727+
|> Option.is_some
727728
in
728-
let caseWithPatHole =
729+
let hasCaseWithPatHole =
729730
cases
730731
|> List.find_opt (fun case -> isPatternHole case.Parsetree.pc_lhs)
732+
|> Option.is_some
731733
in
732-
match (caseWithPatHole, caseWithCursor) with
733-
| _, Some _ ->
734+
match (hasCaseWithPatHole, hasCaseWithCursor) with
735+
| _, true ->
734736
(* Always continue if there's a case with the cursor *)
735737
setLookingForPat ctxPath
736-
| Some _, None ->
738+
| true, false ->
737739
(* If there's no case with the cursor, but a broken parser case, complete for the top level. *)
738740
setResult
739741
(Completable.Cpattern {typ = ctxPath; nested = []; prefix = ""})
740-
| None, None -> ()))
742+
| false, false -> ()))
741743
| _ -> unsetLookingForPat ()
742744
in
743745

0 commit comments

Comments
 (0)