Preserve unwrapped comments#1352
Preserve unwrapped comments#1352gpetiot merged 1 commit intoocaml-ppx:masterfrom gpetiot:preserve-unwrapped-comments
Conversation
jberdine
left a comment
There was a problem hiding this comment.
Is there any motivation for this change of behavior except when using ocamlformat in combination with ocp-indent? The functionality that adjusts the indentation of comments was a very nice addition that notably improves the output and usability. In particular, there isn't anything in #1165 that indicates a bug or even poor behavior of ocamlformat. I'm not very happy to see it go for no other reason. Could this be guarded under --ocp-indent-compat? Looking forward to when ocamlformat has editor integration, then we won't want to have lost this comment indentation functionality.
Separately, in the diff output there are a few changes similar to:
diff --git a/infer/src/base/Config.ml b/infer/src/base/Config.ml
index feb179d64..52742a1fc 100644
--- a/infer/src/base/Config.ml
+++ b/infer/src/base/Config.ml
@@ -1629,7 +1629,8 @@ and nullsafe_optimistic_third_party_params_in_non_strict =
Historically this is because there was no actionable way to change third party annotations.
Now that we have such a support, this behavior should be reconsidered, provided
our tooling and error reporting is friendly enough to be smoothly used by developers.
- *) ~default:true
+ *)
+ ~default:true
"Nullsafe: in this mode we treat non annotated third party method params \
as if they were annotated as nullable."I don't know how related they are to the rest of this PR, but changes like this that add breaks after multi-line comments are a notable improvement. These changes are a bug fix.
| Placement of documentation comments on `val` and `external` items is now | ||
| controled by `doc-comments` unless this option is set. | ||
|
|
||
| #### Bug fixes |
There was a problem hiding this comment.
It isn't clear to me that this is a bug fix, seems more like a feature
That's a good point, it's better to guard this feature by the |
|
This one is good to rebase and merge, right? |
|
I have setup a branch for JaneStreet so they can test this feature (and more JaneStreet centric features in the future), I'm waiting for feedback before merging it in master. |
CHANGES:
#### Changes
+ Do not break inline elements such as `{i blah}` in docstrings (ocaml-ppx/ocamlformat#1346, @jberdine)
+ Distinguish hash-getter from hash-comparison infix operators. Operators of the form `#**#` or `#**.` where `**` can be 0 or more operator chars are considered getter operators and are not surrounded by spaces, as opposed to regular infix operators (ocaml-ppx/ocamlformat#1376, @gpetiot)
+ Type constraint on return type of functions is now always printed before the function body (ocaml-ppx/ocamlformat#1381, ocaml-ppx/ocamlformat#1397, @gpetiot)
#### Bug fixes
+ Restore previous functionality for pre-post extension points (ocaml-ppx/ocamlformat#1342, @jberdine)
+ Fix extra break before `function` body of a `fun` (ocaml-ppx/ocamlformat#1343, @jberdine)
Indent further args of anonymous functions (ocaml-ppx/ocamlformat#1440, @gpetiot)
+ Do not clear the emacs `*compilation*` buffer on successful reformat (ocaml-ppx/ocamlformat#1350, @jberdine)
+ Fix disabling with attributes on OCaml < 4.08 (ocaml-ppx/ocamlformat#1322, @emillon)
+ Preserve unwrapped comments by not adding artificial breaks when `wrap-comments=false` and `ocp-indent-compat=true` are set to avoid interfering with ocp-indent indentation. (ocaml-ppx/ocamlformat#1352, @gpetiot)
+ Break long literal strings at the margin (ocaml-ppx/ocamlformat#1367, @gpetiot)
+ Break after a multiline argument in an argument list (ocaml-ppx/ocamlformat#1360, @gpetiot)
+ Remove unnecessary parens around object (ocaml-ppx/ocamlformat#1379, @gpetiot)
+ Fix placement of comments on constants (ocaml-ppx/ocamlformat#1383, @gpetiot)
+ Do not escape arguments of some Odoc tags (ocaml-ppx/ocamlformat#1391, 1408, @gpetiot, @Julow)
The characters `[]{}` must not be escaped in the arguments of `@raise`, `@author`, `@version` and others.
+ Fix missing open line between multi-line let-binding with poly-typexpr (ocaml-ppx/ocamlformat#1372, @jberdine)
+ Remove trailing space after expression when followed by an attribute and break before attributes attached to multi-line phrases (ocaml-ppx/ocamlformat#1382, @gpetiot)
+ Do not add a space to minimal comments `(* *)`, `(** *)` and `(*$ *)` (ocaml-ppx/ocamlformat#1407, @gpetiot)
+ Fix attributes position in labelled arguments type (ocaml-ppx/ocamlformat#1434, @gpetiot)
+ Add missing parens around type annotation in anonymous function (ocaml-ppx/ocamlformat#1433, @gpetiot)
+ Fix alignment of 'then' keyword in parenthesised expression (ocaml-ppx/ocamlformat#1421, @gpetiot)
#### New features
+ Support quoted extensions (added in ocaml 4.11) (ocaml-ppx/ocamlformat#1405, @gpetiot)
+ Recognise eliom file extensions (ocaml-ppx/ocamlformat#1430, @jrochel)
The goal is to:
We have to insert a break to preserve #912 and #1100 but we have to do the least possible work (to trying to be too smart), as the wrapping is disabled it's okay not to be optimal and we should be able to preserve as much as possible from the comment shape of the input.
I'm not very satisfied with using
break_unless_newlinehere as I aimed at removing every use of this function but didn't find any alternative so far.Diff of test_branch with the
janestreetprofile (due to having a break):Diff of test_branch with the
conventionalprofile (due to having a break):