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

Incorrect indentation of inner keyword arguments when aligning equal signs in out keyword arguments #879

Open
jonniediegelman opened this issue Oct 16, 2024 · 3 comments

Comments

@jonniediegelman
Copy link

jonniediegelman commented Oct 16, 2024

This

function return_blah(; kwargs...)
    return Blah(;
        short_int            = 1,
        looooooooooooong_int = 2,
        named_tuple          = (
            inner1 = 3,
            inner2 = 4
        ),
        kwargs...,
    )
end

gets formatted to this

function return_blah(; kwargs...)
    return Blah(;
        short_int            = 1,
        looooooooooooong_int = 2,
        named_tuple          = (
        inner1 = 3,
        inner2 = 4
    ),
        kwargs...,
    )
end

which has obviously incorrect indentation for inner1 and inner2. When I don't line up the equal symbols like this, though, things don't get reformatted:

function return_blah(; kwargs...)
    return Blah(;
        short_int = 1,
        looooooooooooong_int = 2,
        named_tuple = (
            inner1 = 3,
            inner2 = 4,
        ),
        kwargs...,
    )
end

This is all using format with the default options. It's been this way pre- and post-v.2.0

@domluna
Copy link
Owner

domluna commented Oct 16, 2024

this seems like a bug with the align_assignments=true option

@domluna
Copy link
Owner

domluna commented Oct 19, 2024

@jonniediegelman

I've having a difficult time reproducing this, could you verify the options and/or .JuliaFormatter.toml config you're using?

@jonniediegelman
Copy link
Author

Oh, this is really odd. It only happens when the file is placed in a certain directory structure. I'm pulling the exact same files out and putting them in a test directory and all of the sudden they're not hitting this issue. And I checked that the file is actually being formatted by adding a lot of whitespace to the end of the file, which the formatter then trims.

Let me see if I can reproduce this in a way that I can post here.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants