Releases: JuliaEditorSupport/JuliaFormatter.jl
v2.6.3
JuliaFormatter v2.6.3
Fixed a bug where formatting binary expressions with extraneous blank lines was not idempotent. (#1049, #1050)
Fixed a bug where formatting expressions with semicolons (e.g. a1; a2) inside a try/catch block was not idempotent. (#1051, #1050)
Improved the error message emitted when calling JuliaFormatter.format() with an invalid argument. (#830, #1047)
Merged pull requests:
- stop using *fmt test helpers (#1043) (@penelopeysm)
- Fix stack overflow on format() (#1047) (@penelopeysm)
- Update default style tests, fix binary op nesting idempotence bug (#1050) (@penelopeysm)
Closed issues:
- Invalid formatting of array expression (#622)
- plus sign on JuMP expression breaks formatter (#642)
- Syntax change in macro call produces erroneous code. (#669)
- JuliaFormatter deletes comments after trailing comma (#690)
- Toggling formatting fails if there's consecutive format comments (#696)
- Incorrect substitution of
=toinin broadcasted expression with generator (#797) - ERROR: StackOverflowError: (#830)
- Breaks for unicode operators in module imports (#856)
- Error when formatting struct with specific comments (#924)
<foo>fmttest helpers silently does the wrong thing (probably?) (#1042)- Lots of blank lines not idempotent (#1049)
- Block with semicolons in
try/catchnot idempotent (#1051)
v2.6.2
JuliaFormatter v2.6.2
Re-enabled always_use_return=true for BlueStyle, in line with the Blue style guide. (#906, #1041)
Merged pull requests:
- Add
always_use_return=truefor BlueStyle (#1041) (@penelopeysm)
Closed issues:
returnforgotten when changing an inline functionf(x) = ...into afunction f; ...; endblock (#906)
v2.6.1
JuliaFormatter v2.6.1
Fixed a number of bugs where newlines in array literals were not being correctly handled, which caused JuliaFormatter to output invalid code (or worse!) silently different code. (#1029, #1037, #1038, #1039)
Closed issues:
- Disable formatting multi-line comment inline (#241)
- julia fortmatter does not work as expected in vscode (#446)
- Parse error (integer literals and broadcasting inside
[]) (#860) LoadErrorfor certain sub/superscript variables:a = - ᶠb(#885)publickeyword is misformatted (#890)- v2 changes formatting (#894)
- Closure with boolean expression (#902)
- Parentheses added to anonymous function parameters (#904)
- Parentheses around unary ops (#907)
- Parsing error of a generated docstring (#916)
indent_submodule = truefails to have an effect (#919)- v2.0 regression: line too long kwargs (#920)
- Comment gets duplicated (#925)
- Contributing docs page (#1027)
- ncat bug (#1037)
- More hcat bugs (#1038)
v2.6.0
JuliaFormatter v2.6.0
Fixed a number of cases where the left-hand operand of binary operators would be aggressively nested. (In general, it is better to nest the right-hand operand as that keeps as much of the operation as possible on the same line.) These fixes were applied to DefaultStyle and thus should propagate to other styles as well. On top of this, SciMLStyle goes slightly further and also allows expressions to extend beyond the stated margin in the interests of not nesting the LHS. (#998, #1012)
Added a new formatting option, sciml_margin_overrun, which controls the extent to which SciMLStyle allows expressions to extend beyond the margin in order to avoid nesting the LHS of binary operators. The default is 20, but it can be set to 0 to prevent this behaviour if undesired. This option has no effect for styles apart from SciML. (#998)
Merged pull requests:
- reduce SciML indentation on lhs of ops, make soft margin overrun configurable (#998) (@svchb)
- Avoid nesting LHS if not over margin and if RHS can be nested (#1012) (@penelopeysm)
- Docs for sciml style and options (#1034) (@penelopeysm)
v2.5.6
JuliaFormatter v2.5.6
Fixed a bug where JuliaFormatter would emit invalid code when parsing an if/elseif with a block condition (e.g. (a; b) or begin ... end). (#1025, #1026)
The same bug was present for while loops with similar block conditions.
Although Julia would still parse the code correctly, the output was ugly.
This PR therefore also fixes this. (#1026)
Merged pull requests:
- fix block if conditions (#1026) (@penelopeysm)
Closed issues:
v2.5.5
JuliaFormatter v2.5.5
Fixed a number of issues with pipe_to_function_call=true:
-
Various constructions such as
x .|> f(),x .|> !, andx |> a + bwere being transformed into code that had a different meaning from the original. (#927, #1023) -
Transforming pipes inside macros was fundamentally dangerous.
This patch conservatively refuses to transform pipes inside macros. (#439, #1023) -
Transforming pipes inside an
Exprchanges theExpr.
This patch prevents this. (#1023) -
The expression
1 .|> (sin, cos)cannot be transformed into a function call as there is no equivalent syntax for this. This patch leaves such expressions unchanged. (#647, #1023) -
For the transformations that do happen, this patch elides unnecessary parentheses. For example
(x) |> fis now transformed intof(x)rather thanf((x)). (#1023) -
Fixed cases where newly transformed function calls would be generated with the wrong nesting, leading to a loss of idempotency. (#1023)
Finally, this patch also causes a warning to be emitted whenever a pipe is transformed into a function call. (#1023)
This is because |> is an ordinary Julia function, and can be overloaded by users such that x |> f may not always be equivalent to f(x).
A formatter should never change the meaning of code.
Thus, it is possible, or even likely, that this option will be completely removed in the future (it could be turned into a linter rule, for example, where the user can be alerted to the presence of |> in their code; but the formatter should not change it).
Merged pull requests:
- Fix various issues with
pipe_to_function_call(#1023) (@penelopeysm)
Closed issues:
v2.5.4
JuliaFormatter v2.5.4
Fixed a bug where jlfmt would not use the style set in a .JuliaFormatter.toml configuration file (unless --prioritize-config-file was specified) (#951, #1021).
Fixed a bug where JuliaFormatter (both the library and app) would not correctly ignore files in subdirectories on Windows due to path separator differences (#898, #1021).
Merged pull requests:
- Fix jlfmt not picking up style from config file + ignore paths not working on Windows (#1021) (@penelopeysm)
- Clarify changelog (#1022) (@penelopeysm)
Closed issues:
v2.5.3
JuliaFormatter v2.5.3
Fixed a bug where postfix operators (e.g. transpose) were not being recognised as unary operators, causing formatting to output unparseable code in some circumstances (#1011).
Improved consistency when parenthesising the value of a keyword argument with whitespace_in_kwargs=false, e.g., (; x=-pi/2) is now formatted as (; x=(-pi/2)) (#1011).
Merged pull requests:
- Refactor
is_unaryandp_kw, improve consistency of kwarg parenthesisation (#1011) (@penelopeysm) - FormatBot improvements (#1015) (@penelopeysm)
- Completely refresh docs (#1019) (@penelopeysm)
Closed issues:
v2.5.2
JuliaFormatter v2.5.2
Fixed a bug where, under SciML style, indentations of bracketed expressions on the RHS of assignments were being removed for anything on the second line onwards (#935, #1006).
Merged pull requests:
- Delete extra SciML nesting code paths (#1006) (@penelopeysm)
- Add FormatBot workflow (#1008) (@penelopeysm)
- FormatBot part 2 (#1009) (@penelopeysm)
- FormatBot Part 3: fix more bugs (#1010) (@penelopeysm)
Closed issues:
v2.5.1
JuliaFormatter v2.5.1
Fix some formatting regressions introduced in v2.5.0.
In particular, this version:
- no longer aggressively adds spaces around
x=>yandx->y(unless spaces are already present).
This matches the behaviour of other operators e.g.x+y. - no longer adds spaces around assignments in square brackets, for example
a[b=1]is now left unchanged, rather than being changed toa[b = 1]. - no longer adds parentheses around field access in ranges, for example
[1:a.b]is now left unchanged, rather than being changed to[1:(a.b)].
Some of these may be configurable in the future.
Merged pull requests:
- Fix formatting regressions in v2.5.0 (#996) (@penelopeysm)