Skip to content

Commit 56e45f1

Browse files
factor out common logic for merlin file loading
Signed-off-by: Will Thomas <[email protected]>
1 parent 8eb27b7 commit 56e45f1

File tree

1 file changed

+7
-6
lines changed

1 file changed

+7
-6
lines changed

bin/ocaml/ocaml_merlin.ml

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -99,6 +99,11 @@ end = struct
9999
let load_merlin_file file =
100100
(* We search for an appropriate merlin configuration in the current
101101
directory and its parents *)
102+
let get_file_config_at_path p =
103+
match Merlin.Processed.load_file p with
104+
| Error msg -> Some (Merlin_conf.make_error msg)
105+
| Ok config -> Merlin.Processed.get config ~file
106+
in
102107
let basename = Path.Build.set_extension file ~ext:"" |> Path.Build.basename in
103108
let good_names =
104109
List.map
@@ -118,18 +123,14 @@ end = struct
118123
with
119124
| Some p ->
120125
(* Found exact match: we are done *)
121-
(match Merlin.Processed.load_file p with
122-
| Error msg -> Some (Merlin_conf.make_error msg)
123-
| Ok config -> Merlin.Processed.get config ~file)
126+
get_file_config_at_path p
124127
| None ->
125128
(* looking for approximate match *)
126129
(match
127130
List.find_map merlin_paths ~f:(fun file_path ->
128131
(* FIXME we are racing against the build system writing these
129132
files here *)
130-
match Merlin.Processed.load_file file_path with
131-
| Error msg -> Some (Merlin_conf.make_error msg)
132-
| Ok config -> Merlin.Processed.get config ~file)
133+
get_file_config_at_path file_path)
133134
with
134135
| Some p -> Some p
135136
| None ->

0 commit comments

Comments
 (0)