Skip to content

Commit

Permalink
ocp-indent-compat: Remove extra newline in empty comments (#2365)
Browse files Browse the repository at this point in the history
  • Loading branch information
Julow authored May 24, 2023
1 parent bc6425d commit 04d8bfb
Show file tree
Hide file tree
Showing 5 changed files with 8 additions and 2 deletions.
2 changes: 1 addition & 1 deletion CHANGES.md
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
- Restore short form formatting of record field aliases (#2282, @gpetiot)
- Tweaks the JaneStreet profile to be more consistent with ocp-indent (#2214, #2281, #2284, #2289, #2299, #2302, #2309, #2310, #2311, #2313, #2316, #2362, #2363, @gpetiot, @Julow)
- Improve formatting of class signatures (#2301, @gpetiot, @Julow)
- JaneStreet profile: treat comments as doc-comments (#2261, #2344, #2354, @gpetiot, @Julow)
- JaneStreet profile: treat comments as doc-comments (#2261, #2344, #2354, #2365, @gpetiot, @Julow)
- Don't indent attributes after a let/val/external (#2317, @Julow)
- Adjust indentation of class-expr function body (#2328, @gpetiot)

Expand Down
2 changes: 1 addition & 1 deletion lib/Cmts.ml
Original file line number Diff line number Diff line change
Expand Up @@ -562,7 +562,7 @@ module Ocp_indent_compat = struct
let pre, doc, post =
let lines = String.split_lines txt in
match lines with
| [] -> (false, txt, false)
| [] | [_] -> (false, txt, false)
| h :: _ ->
let pre = String.is_empty (String.strip h) in
let doc = if pre then String.lstrip txt else txt in
Expand Down
2 changes: 2 additions & 0 deletions test/passing/tests/js_source.ml
Original file line number Diff line number Diff line change
Expand Up @@ -7951,3 +7951,5 @@ let _ =
| Some _ -> foo
| None -> baz)
;;

(* *)
2 changes: 2 additions & 0 deletions test/passing/tests/js_source.ml.ocp
Original file line number Diff line number Diff line change
Expand Up @@ -10187,3 +10187,5 @@ let _ =
| Some _ -> foo
| None -> baz)
;;

(* *)
2 changes: 2 additions & 0 deletions test/passing/tests/js_source.ml.ref
Original file line number Diff line number Diff line change
Expand Up @@ -10187,3 +10187,5 @@ let _ =
| Some _ -> foo
| None -> baz)
;;

(* *)

0 comments on commit 04d8bfb

Please sign in to comment.