-
Notifications
You must be signed in to change notification settings - Fork 200
Always treat multiline {|delimited strings|}
as though they are long
#2480
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -89,8 +89,10 @@ let register_file tests fname = | |
let cmd should_fail args = | ||
let cmd_string = String.concat " " args in | ||
if should_fail then | ||
spf {|(with-accepted-exit-codes 1 | ||
(run %s))|} cmd_string | ||
spf | ||
{|(with-accepted-exit-codes 1 | ||
(run %s))|} | ||
cmd_string | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This output can be achieved by tweaking |
||
else spf {|(run %s)|} cmd_string | ||
|
||
let emit_test test_name setup = | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,5 @@ | ||
let _ = {| | ||
let _ = | ||
{| | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The previous output was expected. We call this "docking" in other contextes. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I'll restrict the change to the janestreet profile, then. It is surprising to me, though, that the property used to determine whether to "dock" is the number of characters in the string and not something that more closely relates to how it "looks", like whether the first line is empty, the number of lines, or the length of the longest line. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It's also surprising to me. I tried various rules in #2448 without success, as the changes to existing code is always large and the rule is always arbitrary. Thanks for the ideas, I'll try to come back to this change later. |
||
foo | ||
|
||
bar | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,5 @@ | ||
let _ = {| | ||
let _ = | ||
{| | ||
foo | ||
|
||
bar | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -185,11 +185,13 @@ let this_function_has_a_long_name plus very many arguments = | |
|
||
[%%expect {||}] ;; | ||
|
||
[%expect {| | ||
[%expect | ||
{| | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Same as with |
||
___________________________________________________________ | ||
|}] | ||
|
||
[%%expect {| | ||
[%%expect | ||
{| | ||
___________________________________________________________ | ||
|}] | ||
|
||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,5 @@ | ||
Warning: tests/js_source.ml:155 exceeds the margin | ||
Warning: tests/js_source.ml:9531 exceeds the margin | ||
Warning: tests/js_source.ml:9634 exceeds the margin | ||
Warning: tests/js_source.ml:9693 exceeds the margin | ||
Warning: tests/js_source.ml:9775 exceeds the margin | ||
Warning: tests/js_source.ml:9537 exceeds the margin | ||
Warning: tests/js_source.ml:9640 exceeds the margin | ||
Warning: tests/js_source.ml:9699 exceeds the margin | ||
Warning: tests/js_source.ml:9781 exceeds the margin |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3154,7 +3154,8 @@ module FM_valid = F (struct | |
type t = int | ||
end) | ||
|
||
[%%expect {| | ||
[%%expect | ||
{| | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The docking behavior could be specially supported again if needed. |
||
module M_valid : S | ||
module FM_valid : S | ||
|}] | ||
|
@@ -3170,7 +3171,8 @@ end = struct | |
let x = ref 0 | ||
end | ||
|
||
[%%expect {| | ||
[%%expect | ||
{| | ||
module Foo : sig type t val x : t ref end | ||
|}] | ||
|
||
|
@@ -3184,7 +3186,8 @@ end = struct | |
let x = ref 0 | ||
end | ||
|
||
[%%expect {| | ||
[%%expect | ||
{| | ||
module Bar : sig type t [@@immediate] val x : t ref end | ||
|}] | ||
|
||
|
@@ -3194,7 +3197,8 @@ let test f = | |
Sys.time () -. start | ||
;; | ||
|
||
[%%expect {| | ||
[%%expect | ||
{| | ||
val test : (unit -> 'a) -> float = <fun> | ||
|}] | ||
|
||
|
@@ -3204,7 +3208,8 @@ let test_foo () = | |
done | ||
;; | ||
|
||
[%%expect {| | ||
[%%expect | ||
{| | ||
val test_foo : unit -> unit = <fun> | ||
|}] | ||
|
||
|
@@ -3214,7 +3219,8 @@ let test_bar () = | |
done | ||
;; | ||
|
||
[%%expect {| | ||
[%%expect | ||
{| | ||
val test_bar : unit -> unit = <fun> | ||
|}] | ||
|
||
|
@@ -10330,8 +10336,10 @@ zzzzzzzzzzzzzzzzzzzzzzzzzzzz | |
*) | ||
(*$*) | ||
|
||
(*$ {| | ||
f|} *) | ||
(*$ | ||
{| | ||
f|} | ||
*) | ||
|
||
let () = | ||
match () with | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's generally not a good idea to put a break at the end of a box as it interferes with the formatting of the containing expression:
Instead, we write rules that can be followed when formatting the containing expression. For example,
is_simple
,break_between
, and more defined inAst
. This is more or less done infmt_args_grouped
.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for pointing this out, I'll take a look at the PR you linked above and try to come up with a fix.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It turns out that, as far as I can tell, semicolons after multiline strings still format fine in the janestreet profile.
I have pushed a commit that restricts the new behavior to the janestreet profile, though.