Skip to content

Erroneous behaviour while formatting with expert #215

@Terbium-135

Description

@Terbium-135

This is with 583ee15 (and Zed editor - I can't test with other editors right now)
Might be the reason for / or connected to: #184

Given this snippet:

  @test %{
    a: :a,
    b: :b
  }

After adding a few leading spaces in front of b: :b and doing a reformat with expert - (might have to repeat this several times) there is suddenly an error message unexpected expression after keyword list [...]

Image

expert.log:

04:07:43.093 [debug] handled request client -> server textDocument/hover in 20ms
04:07:43.180 [debug] handled request client -> server textDocument/codeAction in 11ms
04:07:44.562 [error] Formatter failed %SyntaxError{file: "/home/elixir-dev/projects/ganymed/lib/backend/tasks/CreateInvoiceZugferdWithVerification.ex", line: 868, column: 8, snippet: "      ],", description: "unexpected expression after keyword list. Keyword lists must always come last in lists and maps. Therefore, this is not allowed:\n\n    [some: :value, :another]\n    %{some: :value, another => value}\n\nInstead, reorder it to be the last entry:\n\n    [:another, some: :value]\n    %{another => value, some: :value}\n\nSyntax error after: ','"}
04:07:44.562 [debug] handled request client -> server textDocument/formatting in 26ms
04:07:44.605 [debug] Node port message: 
04:07:44.604 [info] Plugins found 0 results in 0.013 ms

Another example:

    ~H"""
    <span class={["mr-3 mb-2 rounded-lg bg-yellow-700 py-1 pr-3 pl-2", @class]}>
        {render_slot(@inner_block)}
    </span>
    """

Inserting leading spaces in front of {render_slot(@inner_block)}, formatting gives

Image

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions