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

Comments inside function calls are moved to the end #562

Open
fredrikekre opened this issue Mar 23, 2022 · 7 comments
Open

Comments inside function calls are moved to the end #562

fredrikekre opened this issue Mar 23, 2022 · 7 comments
Labels
bug Something isn't working enhancement New feature or request

Comments

@fredrikekre
Copy link

Not sure if this is a conscious choice, or a bug:

julia> using JuliaFormatter

julia> code = """
       f(x, #= y,=# z)
       """;

julia> print(code)
f(x, #= y,=# z)

julia> print(format_text(code))
f(x, z) #= y,=#
@domluna
Copy link
Owner

domluna commented Mar 24, 2022

right now comments like this are assumed to be "inline comments" so they're appended. It's just a simpler implementation atm. Printing this out right might not actually be that tricky though.

@domluna domluna added bug Something isn't working enhancement New feature or request labels Mar 24, 2022
@domluna
Copy link
Owner

domluna commented Apr 5, 2022

should the #= comment =# length be factored into the maximum margin or not? I'm leaning towards no since it's not actually code

@fredrikekre
Copy link
Author

I would say yes, I don't consider character limits to only apply to code. Are trailing comments not counted towards the limit?

@domluna
Copy link
Owner

domluna commented Apr 5, 2022

they are not

foo(a, b, c) # comment

# would you want this to be

foo(
    a,
    b,
    c,
) # comment

# because `# comment` is over the margin?

there's also a case to be made there's far less control over how a comment can be broken over multiple lines vs. code

If the comment is not trailing then I think there's a case for considering the length, it could go either way.

@fredrikekre
Copy link
Author

I would want it to become

# comment
foo(a, b, c)

@fredrikekre
Copy link
Author

But to get back to the original issue, I think it would be fine if it counted for non-trailing comments and the result was

f(
  x,
  #= y,=#
  z
)

without touching/breaking up the comment (i.e. if the comment line alone would be over the limit that would be allowed).

@domluna
Copy link
Owner

domluna commented Apr 9, 2022

that makes sense it could be treated similar to a multiline string

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants