Skip to content

Commit ca375bb

Browse files
authored
Fix the handling of .ocamlformat-ignore on Windows (#1752)
1 parent 269984a commit ca375bb

File tree

2 files changed

+12
-9
lines changed

2 files changed

+12
-9
lines changed

CHANGES.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,8 @@
1414

1515
+ Add missing parentheses around constructor used as indexing op (#1740, @gpetiot)
1616

17+
+ Honour .ocamlformat-ignore on Windows (#1752, @nojb)
18+
1719
#### Changes
1820

1921
#### New features

lib/Conf.ml

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1857,16 +1857,16 @@ let dot_ocamlformat_ignore = ".ocamlformat-ignore"
18571857

18581858
let dot_ocamlformat_enable = ".ocamlformat-enable"
18591859

1860-
let rec collect_files ~enable_outside_detected_project ~root ~segs ~ignores
1861-
~enables ~files =
1860+
let rec collect_files ~enable_outside_detected_project ~root ~volume ~segs
1861+
~ignores ~enables ~files =
18621862
match segs with
18631863
| [] | [""] -> (ignores, enables, files, None)
18641864
| "" :: upper_segs ->
1865-
collect_files ~enable_outside_detected_project ~root ~segs:upper_segs
1866-
~ignores ~enables ~files
1865+
collect_files ~enable_outside_detected_project ~root ~volume
1866+
~segs:upper_segs ~ignores ~enables ~files
18671867
| _ :: upper_segs ->
18681868
let sep = Fpath.dir_sep in
1869-
let dir = String.concat ~sep (List.rev segs) |> Fpath.v in
1869+
let dir = Fpath.v (volume ^ String.concat ~sep (List.rev segs)) in
18701870
let ignores =
18711871
let filename = Fpath.(dir / dot_ocamlformat_ignore) in
18721872
if Fpath.exists filename then filename :: ignores else ignores
@@ -1886,8 +1886,8 @@ let rec collect_files ~enable_outside_detected_project ~root ~segs ~ignores
18861886
if is_project_root ~root dir && not enable_outside_detected_project
18871887
then (ignores, enables, files, Some dir)
18881888
else
1889-
collect_files ~enable_outside_detected_project ~root ~segs:upper_segs
1890-
~ignores ~enables ~files
1889+
collect_files ~enable_outside_detected_project ~root ~volume
1890+
~segs:upper_segs ~ignores ~enables ~files
18911891

18921892
exception Conf_error of string
18931893

@@ -1996,10 +1996,11 @@ let build_config ~enable_outside_detected_project ~root ~file ~is_stdin =
19961996
let vfile = Fpath.v file in
19971997
let file_abs = Fpath.(vfile |> to_absolute |> normalize) in
19981998
let dir = Fpath.(file_abs |> split_base |> fst) in
1999+
let volume, dir = Fpath.split_volume dir in
19992000
let segs = Fpath.segs dir |> List.rev in
20002001
let ignores, enables, files, project_root =
2001-
collect_files ~enable_outside_detected_project ~root ~segs ~ignores:[]
2002-
~enables:[] ~files:[]
2002+
collect_files ~enable_outside_detected_project ~root ~volume ~segs
2003+
~ignores:[] ~enables:[] ~files:[]
20032004
in
20042005
let files =
20052006
match (xdg_config, enable_outside_detected_project) with

0 commit comments

Comments
 (0)