Skip to content
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

fix for #753 #754

Merged
merged 4 commits into from
Sep 13, 2023
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Project.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
name = "JuliaFormatter"
uuid = "98e50ef6-434e-11e9-1051-2b60c6c9e899"
authors = ["Dominique Luna <[email protected]>"]
version = "1.0.36"
version = "1.0.37"

[deps]
CSTParser = "00ebfdb7-1f24-5e51-bd34-a7502290713f"
Expand Down
9 changes: 8 additions & 1 deletion src/styles/sciml/nest.jl
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,14 @@ function n_binaryopcall!(ss::SciMLStyle, fst::FST, s::State; indent::Int = -1)
line_margin = s.line_offset + length(fst) + fst.extra_margin
if line_margin > s.opts.margin &&
fst.ref !== nothing &&
CSTParser.defines_function(fst.ref[])
(
Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@ChrisRackauckas should another check for short_to_long_function_def be added here or is it intentional to not check?

Copy link
Owner Author

@domluna domluna Sep 9, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

the check is now in the pass itself so all that's left is verify that we can to make try transform always, even if short_to_long_function_def is set to false

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

should another check for short_to_long_function_def be added here or is it intentional to not check?

That I don't know, @YingboMa wrote that I think?

!parent_is(
fst.ref[],
n -> is_function_or_macro_def(n) || n.head == :macrocall;
ignore = n -> is_block(n),
)
)
CSTParser.defines_function(fst.ref[])
transformed = short_to_long_function_def!(fst, s)
transformed && nest!(style, fst, s)
end
Expand Down
2 changes: 1 addition & 1 deletion test/issues.jl
Original file line number Diff line number Diff line change
Expand Up @@ -1704,6 +1704,6 @@
0.0008014; 0.0001464; 2.67e-05; 4.8e-6; 9e-7; 0.0619917; 1.2444292; 0.0486676;
199.9383546; 137.4267984; 1.5180203; 1.5180203]
"""
@test fmt(str_, 4, 92, join_lines_based_on_source=true) == str
@test fmt(str_, 4, 92, join_lines_based_on_source = true) == str
end
end
6 changes: 2 additions & 4 deletions test/sciml_style.jl
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,8 @@
m.inv_match === nothing && throw(ArgumentError("Backwards matching not defined. `complete` the matching first."))
"""
formatted_str = raw"""
@noinline function require_complete(m::Matching)
m.inv_match === nothing &&
throw(ArgumentError("Backwards matching not defined. `complete` the matching first."))
end
@noinline require_complete(m::Matching) = m.inv_match === nothing &&
throw(ArgumentError("Backwards matching not defined. `complete` the matching first."))
"""
@test format_text(str, SciMLStyle()) == formatted_str

Expand Down
Loading