JuliaFormatter.jl icon indicating copy to clipboard operation
JuliaFormatter.jl copied to clipboard

YASStyle bug with blocks, line splitting and operators

Open c42f opened this issue 2 years ago • 0 comments

Here's a case of failed formatting with YASStyle:

julia> Text(text)
y == begin
    x = func(args, args, args, args, args, args, args, args, args, args, args, args, args, args, args, args, args, args, args, args)
    if cond
        true
    else
        false
    end
end


julia> Text(JuliaFormatter.format_text(text, YASStyle()))
y == begin
     x = func(args, args, args, args, args, args, args, args, args, args, args, args, args,
              args, args, args, args, args, args, args)
     if cond
     true
     else
     false
     end
     end

It appears this occurs with the combination of

  • The operator ==
  • The long line in x = ... which needs to be folded
  • The block structure

For reference, here's the code before reduction:

@test :ok === foo(x,y) do
    try
        response = HTTP.get("https://127.0.0.1/configuration"; status_exception=false, sslconfig=get_tls_config())
        if response.status == 200
            config_str = String(response.body)
            true
        else
            false
        end
    catch ex
        false
    end
end

c42f avatar Mar 03 '22 01:03 c42f