Skip to content

Releases: JuliaEditorSupport/JuliaFormatter.jl

v2.6.3

07 Jun 14:55
10deb15

Choose a tag to compare

JuliaFormatter v2.6.3

Diff since v2.6.2

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:

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 = to in in 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>fmt test helpers silently does the wrong thing (probably?) (#1042)
  • Lots of blank lines not idempotent (#1049)
  • Block with semicolons in try/catch not idempotent (#1051)

v2.6.2

06 Jun 21:49
546a67e

Choose a tag to compare

JuliaFormatter v2.6.2

Diff since v2.6.1

Re-enabled always_use_return=true for BlueStyle, in line with the Blue style guide. (#906, #1041)

Merged pull requests:

Closed issues:

  • return forgotten when changing an inline function f(x) = ... into a function f; ...; end block (#906)

v2.6.1

06 Jun 21:03
71cbe42

Choose a tag to compare

JuliaFormatter v2.6.1

Diff since v2.6.0

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)
  • LoadError for certain sub/superscript variables: a = - ᶠb (#885)
  • public keyword 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 = true fails 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

04 Jun 13:45
cf994d6

Choose a tag to compare

JuliaFormatter v2.6.0

Diff since v2.5.6

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

03 Jun 12:27
ee8a229

Choose a tag to compare

JuliaFormatter v2.5.6

Diff since v2.5.5

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:

Closed issues:

  • LoadError: MethodError: no method matching length(::Nothing) (#427)
  • Incorrect parsing of certain catch syntax (#782)
  • Failure to enforce line length in a testset (#911)
  • if or elseif with block condition fails (#1025)

v2.5.5

02 Jun 02:14
09da91d

Choose a tag to compare

JuliaFormatter v2.5.5

Diff since v2.5.4

Fixed a number of issues with pipe_to_function_call=true:

  • Various constructions such as x .|> f(), x .|> !, and x |> a + b were 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 Expr changes the Expr.
    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) |> f is now transformed into f(x) rather than f((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:

Closed issues:

  • VSCode Extension Replaces Pipes with Function Calls (#439)
  • format not idempotent, sometimes breaks code (#579)
  • Broadcast collection of functions (#647)
  • Incorrect reformatting of broadcasted pipe, i.e., .|> expression (#927)

v2.5.4

01 Jun 13:55
e76cfb5

Choose a tag to compare

JuliaFormatter v2.5.4

Diff since v2.5.3

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:

Closed issues:

  • Ignore field does not work on windows with unix path separator (#898)
  • When using CLI jlfmt, style is never taken from config file, unless switch --prioritize-config-file is given (#951)

v2.5.3

01 Jun 01:24
6667f1b

Choose a tag to compare

JuliaFormatter v2.5.3

Diff since v2.5.2

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:

Closed issues:

  • Bug Report: Julia Language Server crashes on formatting incomplete code in Cursor (#923)
  • Formatting of f(*, +, a, b) (#926)
  • FormatBot problems / enhancements (#1014)

v2.5.2

30 May 16:15
0ed21d9

Choose a tag to compare

JuliaFormatter v2.5.2

Diff since v2.5.1

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:

Closed issues:

  • #933 broke indent of Pair (#935)
  • v2.5.0 changed a lot of formatting (#1002)
  • github bot or similar to test against repositories (#1007)

v2.5.1

28 May 22:36
473f50d

Choose a tag to compare

JuliaFormatter v2.5.1

Diff since v2.5.0

Fix some formatting regressions introduced in v2.5.0.
In particular, this version:

  • no longer aggressively adds spaces around x=>y and x->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 to a[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: